Path::Router::Route;
ATTRIBUTES
path
has Str $.path
This is the full path of the route.
target
has $.target
This is the configured target for the route. This does not have to be set and is not used by the tooling except to return when matching a route.
components
has Str @.components
This is the list of components, basically, all the path parts between "/".
length
has Int $.length
This is the maximum length of path this route can match (unless it's slurpy, then the path has upper limit).
length-without-optionals
has Int $.length-without-optionals
This is the minimum length of path this route can match.
default
has %.defaults
These are the defaults provided for the path. These will used both for path matching and path building.
validations
has %.validations
This defines any validations the route needs to perform for each variable. For
Int
, UInt
, Rat
, Real
, and Num
, it will also cause coercion to
happen on the incoming path components.
conditions
has %.conditions
This defined any conditions to set on the route. When conditions are set, the
conditions are matched against the %context
argument that may be passed to
#method match. Any condition that fails to match will cause the route to fail
to match. This can be useful, for example, for matching against request method
when used to match HTTP requests.
METHODS
method has-defaults
method has-defaults(--> Bool)
Returns True
if this route has any defaults.
method has-validations
method has-validations(--> Bool)
Returns True
if this route has any validations.
method has-validation-for
method has-validation-for(Str $name --> Bool)
Returns True
if this route has a validation with the given $name
.
method has-conditions
method has-conditions(--> Bool)
Returns True
if this route has at least one condition set.
method test-conditions
method test-conditiosn(%context --> Bool)
Given a context to test agains, this will test that context against the conditions set on the route. This test should only be executed if has-conditions
returns True
.
method match
method match(@parts, :%context --> Path::Router::Route::Match)
Returns a defined Path::Router::Route::Match if this route matches the given path parts. Returns an undefined type-object otherwise.
You may provide an optional %context
value when matching. This value is
ignored unless the route being match as a #condition set. In that case, the
conditions are checked against the context. If any condition fails to match, the
route will not match.
Component checks
These methods are called on components, which can be gotten from the #components attribute.
method get-component-name
method get-component-name(Str $component --> Str)
This method will return the variable name of a component for components for
which #method is-component-variable is True
. Do not use this method unless
that test returns True
first.
method is-component-optional
method is-component-optionaal(Str $component --> Bool)
This method will return True
if the component is optional, that is, it has
the "?" or "*" flags set on it.
method is-component-slurpy
method is-component-slurpy(Str $component --> Bool)
This method will return True
if the component is slurpy, that is, it has the
"+" or "*" flags set on it.
method is-component-variable
method is-component-variable(Str $component --> Bool)
This method will return True
if the component is a variable.
AUTHOR
Andrew Sterling Hanenkamp <[email protected]>
Based very closely on the original Perl 5 version by Stevan Little <[email protected]>
COPYRIGHT
Copyright 2015 Andrew Sterling Hanenkamp.
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.