HTTP::Router::Declare
use HTTP::Router::Declare; my $router = router { # path and params match '/' => to { controller => 'Root', action => 'index' }; # path, conditions, and params match '/home', { method => 'GET' } => to { controller => 'Home', action => 'show' }; match '/date/{year}', { year => qr/^\d{4}$/ } => to { controller => 'Date', action => 'by_year' }; # path, params, and nesting match '/account' => to { controller => 'Account' } => then { match '/login' => to { action => 'login' }; match '/logout' => to { action => 'logout' }; }; # path nesting match '/account' => then { match '/signup' => to { controller => 'Users', action => 'register' }; match '/logout' => to { controller => 'Account', action => 'logout' }; }; # conditions nesting match { method => 'GET' } => then { match '/search' => to { controller => 'Items', action => 'search' }; match '/tags' => to { controller => 'Tags', action => 'index' }; }; # params nesting with { controller => 'Account' } => then { match '/login' => to { action => 'login' }; match '/logout' => to { action => 'logout' }; match '/signup' => to { action => 'signup' }; }; # match only match '/{controller}/{action}/{id}.{format}'; match '/{controller}/{action}/{id}'; };
NAKAGAWA Masaki <masaki@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
HTTP::Router, HTTP::Router::Route
To install HTTP::Router, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Router
CPAN shell
perl -MCPAN -e shell install HTTP::Router
For more information on module installation, please visit the detailed CPAN module installation guide.