Router::Simple::Sinatraish - Sinatra-ish routers on Router::Simple
package MySinatraishFramework; use Router::Simple::Sinatraish; sub import { Router::Simple::Sinatraish->export_to_level(1); } sub to_app { my ($class) = caller(0); sub { my $env = shift; if (my $route = $class->router->match($env)) { return $route->{code}->($env); } else { return [404, [], ['not found']]; } }; } package MyApp; use MySinatraishFramework; get '/' => sub { [200, [], ['ok']]; }; post '/edit' => sub { [200, [], ['ok']]; }; any '/any' => sub { [200, [], ['ok']]; }; __PACKAGE__->to_app;
Router::Simple::Sinatraish is toolkit library for sinatra-ish WAF.
Returns this instance of Router::Simple.
get '/' => sub { ... };
Add new route, handles GET method.
post '/' => sub { ... };
Add new route, handles POST method.
any '/' => sub { ... };
Add new route, handles any HTTP method.
any [qw/GET DELETE/] => '/' => sub { ... };
Tokuhiro Matsuno <tokuhirom AAJKLFJEF@ GMAIL COM>
Router::Simple
Copyright (C) Tokuhiro Matsuno
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Router::Simple::Sinatraish, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Router::Simple::Sinatraish
CPAN shell
perl -MCPAN -e shell install Router::Simple::Sinatraish
For more information on module installation, please visit the detailed CPAN module installation guide.