NAME

Router::Dumb::Route - just one dumb route for use in a big dumb router

VERSION

version 0.006

OVERVIEW

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.

PERL VERSION

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.

ATTRIBUTES

target

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.

parts

The parts attribute is an arrayref of strings that make up the route.

constraints

The constraints attribute holds a hashref of Moose type constraints objects, up to one for each placeholder.

METHODS

parts

This method returns a list of the contents of the parts attribute.

part_count

get_part

my $part = $route->get_part( $n );

This returns the string located at position $n in the parts array.

path

This returns the /-joined list of path parts, or the empty string if parts is empty.

normalized_path

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.

is_slurpy

This method returns true if the path ends in the slurpy *.

has_params

This method returns true if any of the route's path parts is a placeholder (i.e., starts with a colon).

constraint_names

This method returns a list of all the placeholders for which a constraint is registered.

constraint_for

my $tc = $route->constraint_for( $placeholder_name );

check

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.

AUTHOR

Ricardo Signes <cpan@semiotic.systems>

COPYRIGHT AND LICENSE

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.