Dispatcher::Small - Small dispatcher with Regular-Expression
use Dispatcher::Small; my $ds = Dispatcher::Small->new( GET => [ qr'^/user/(?<id>.+)' => { action => \&user }, qr'^/' => { action => \&root }, ], POST => [ qr'^/user/(?<id>.+)' => { action => \&user_update }, ], ); my $res = $ds->match({ PATH_INFO => '/user/oreore', REQUEST_METHOD => 'GET', }); ### $res = { action => sub {...}, id => 'oreore' }
"Dispatcher::Small" is a dispatcher class that is written in perl, and is maybe smallest one of them in the world... maybe.
Dispatcher::Small requires perl-5.10 or later.
my %dispatch_rule = ( GET => [ qr'^/user/(?<id>.+)' => \&user, qr'^/' => \&root, ], POST => [ qr'^/user/(?<id>.+)' => \&user_update, ], ); my $object = Dispatcher::Small->new( %dispatch_rule );
Constructor method.
my $res = $object->match($env);
Returns matching result as hashref. $env is environment-values of PSGI.
Copyright (C) ytnobody.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
ytnobody <ytnobody@gmail.com>
To install Dispatcher::Small, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dispatcher::Small
CPAN shell
perl -MCPAN -e shell install Dispatcher::Small
For more information on module installation, please visit the detailed CPAN module installation guide.