Router::Dumb::Route - just one dumb route for use in a big dumb router
version 0.006
Router::Dumb::Route objects represent paths that a Router::Dumb object can route to. They are usually created by calling the add_route method on a router.
add_route
This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
The route's target is a string that can be used, for example, to give a file path or URL for the resource to which the user should be directed. Its meaning is left up to Router::Dumb's user.
The parts attribute is an arrayref of strings that make up the route.
parts
The constraints attribute holds a hashref of Moose type constraints objects, up to one for each placeholder.
constraints
This method returns a list of the contents of the parts attribute.
my $part = $route->get_part( $n );
This returns the string located at position $n in the parts array.
$n
This returns the /-joined list of path parts, or the empty string if parts is empty.
/
This method behaves like path, but placeholder parts are replaced with numbers so that, for example, instead of returning foo/:bar/baz/:quux we would return foo/:1/baz/:2. This normalization is used to prevent route collision.
path
foo/:bar/baz/:quux
foo/:1/baz/:2
This method returns true if the path ends in the slurpy *.
*
This method returns true if any of the route's path parts is a placeholder (i.e., starts with a colon).
This method returns a list of all the placeholders for which a constraint is registered.
my $tc = $route->constraint_for( $placeholder_name );
my $match_or_undef = $route->check( $str );
This is the method used by the router to see if each route will accept the string. If it matches, it returns a match object. Otherwise, it returns false.
Ricardo Signes <cpan@semiotic.systems>
This software is copyright (c) 2022 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Router::Dumb, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Router::Dumb
CPAN shell
perl -MCPAN -e shell install Router::Dumb
For more information on module installation, please visit the detailed CPAN module installation guide.