NAME
Mojolicious::Routes::Match - Routes visitor
SYNOPSIS
use Mojolicious::Controller;
use Mojolicious::Routes;
use Mojolicious::Routes::Match;
# Routes
my $r = Mojolicious::Routes->new;
$r->get('/foo')->to(action => 'foo');
$r->put('/bar')->to(action => 'bar');
# Match
my $c = Mojolicious::Controller->new;
my $m = Mojolicious::Routes::Match->new(PUT => '/bar');
$m->match($r, $c);
say $m->captures->{action};
DESCRIPTION
Mojolicious::Routes::Match is a visitor for Mojolicious::Routes structures.
ATTRIBUTES
Mojolicious::Routes::Match implements the following attributes.
captures
my $captures = $m->captures;
$m = $m->captures({foo => 'bar'});
Captured parameters.
endpoint
my $endpoint = $m->endpoint;
$m = $m->endpoint(Mojolicious::Routes->new);
The route endpoint that actually matched.
root
my $root = $m->root;
$m = $m->root($routes);
The root of the route tree.
stack
my $stack = $m->stack;
$m = $m->stack([{foo => 'bar'}]);
Captured parameters with nesting history.
METHODS
Mojolicious::Routes::Match inherits all methods from Mojo::Base and implements the following new ones.
new
my $m = Mojolicious::Routes::Match->new(GET => '/foo');
my $m = Mojolicious::Routes::Match->new(GET => '/foo', $ws);
Construct a new Mojolicious::Routes::Match object.
match
$m->match(Mojolicious::Routes->new, Mojolicious::Controller->new);
Match against a route tree.
path_for
my $path = $m->path_for;
my $path = $m->path_for(foo => 'bar');
my $path = $m->path_for({foo => 'bar'});
my $path = $m->path_for('named');
my $path = $m->path_for('named', foo => 'bar');
my $path = $m->path_for('named', {foo => 'bar'});
my ($path, $ws) = $m->path_for;
my ($path, $ws) = $m->path_for(foo => 'bar');
my ($path, $ws) = $m->path_for({foo => 'bar'});
my ($path, $ws) = $m->path_for('named');
my ($path, $ws) = $m->path_for('named', foo => 'bar');
my ($path, $ws) = $m->path_for('named', {foo => 'bar'});
Render matching route with parameters into path.