Web::Dispatcher::Simple - Minimalistic routing sugar for your Plack
In Web::Dispatcher::Simple, a route is an HTTP method paired with an URL matching pattern. Each route is associated with a code ref:
# app.psgi use Web::Dispatcher::Simple; my $app = router { get '/api' => sub { my $req = shift; my $res = $req->new_response(200); $res->body('Hello world'); $res; }, post '/comment/{id}' => sub { my ($req, $args) = @_; my $id = $args->{id}; my $res = $req->new_response(200); $res; }, any [ 'GET', 'POST' ] => '/any' => sub { my ( $req, $args ) = @_; my $res = $req->new_response(200); $res->body('any'); $res; }, };
Route patterns may include named parameters, accessible via the args hash:
use Web::Dispatcher::Simple; my $app = router { post '/comment/{id}' => sub { my ($req, $args) = @_; my $id = $args->{id}; my $res = $req->new_response(200); $res; }, };
Web::Dispatcher::Simple is Minimalistic routing sugar for your Plack
This source is in Github:
http://github.com/dann/p5-web-dispatcher-simple
Many thanks to: woremacx
dann <techmemo@gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Web::Dispatcher::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Web::Dispatcher::Simple
CPAN shell
perl -MCPAN -e shell install Web::Dispatcher::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.