Skip to content

Commit

Permalink
add psgi example
Browse files Browse the repository at this point in the history
  • Loading branch information
vti committed Feb 6, 2014
1 parent 4562186 commit 8b5330f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/app.psgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env perl

use strict;
use warnings;

use Routes::Tiny;

my $routes = build_routes();

sub {
my $env = shift;

my $path = $env->{PATH_INFO};
my $method = $env->{REQUEST_METHOD};

if (my $match = $routes->match($path, method => $method)) {
my $action = $match->params->{action};

return [200, [], ['Hello from ' . $action]];
}

return [200, [], ['Not Found']];
};

sub build_routes {

my $routes = Routes::Tiny->new;

$routes->add_route('/:action');

return $routes;
}

0 comments on commit 8b5330f

Please sign in to comment.