Path::AttrRouter - Path router for URLs using the attributes
package MyController; use parent 'Path::AttrRouter::Controller'; sub index :Path { } sub index2 :Path :Args(2) { } sub index1 :Path :Args(1) { } sub index3 :Path :Args(3) { } package MyController::Args; use parent 'Path::AttrRouter::Controller'; sub index :Path :Args(1) { my ($self, $arg) = @_; } package MyController::Regex; use parent 'Path::AttrRouter::Controller'; sub index :Regex('^regex/(\d+)/(.+)') { my ($self, @captures) = @_; } package main; use Path::AttrRouter; my $router = Path::AttrRouter->new( search_path => 'MyController' ); my $m = $router->match('/args/hoge'); print $m->action->name, "\n"; # => 'index' print $m->action->namespace, "\n"; # => 'args' print $m->args->[0], "\n"; # hoge
Path::AttrRouter is a router class specifying definitions by attributes.
This is mainly used for method dispatching in web application frameworks.
my $router = Path::AttrRouter->new(%options)
Options:
Base package namespace of your controller
action_cache path if using action caching
action_cache
The action cache is aimed at impermanent environment, e.g. CGI or development.
$router->get_action($name:Str, $namespace:Str)
Returns single action object of $router->action_class
$router->action_class
$router->get_actions($name:Str, $namespace:Str)
Returns action objects of array which is bunch of actions
$router->make_action_cache
Make action cache
$router->match($path:Str $condition:HashRef)
Returns Path::AttrRouter::Match> object
Path::AttrRouter::Match
$router->print_table
Draw dispatching table.
Daisuke Murase <typester@cpan.org>
Copyright (c) 2009 by KAYAC Inc.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install Path::AttrRouter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Path::AttrRouter
CPAN shell
perl -MCPAN -e shell install Path::AttrRouter
For more information on module installation, please visit the detailed CPAN module installation guide.