++ed by:
MRAMBERG MATTP FAYLAND KOORCHIK DCPETROV

118 PAUSE users
148 non-PAUSE users.

Marcus Ramberg
and 1 contributors

NAME

Mojolicious::Routes::Match - Routes visitor

SYNOPSIS

  use Mojolicious::Routes;
  use Mojolicious::Routes::Match;

  # Routes
  my $r = Mojolicious::Routes->new;
  $r->route('/foo')->to(action => 'foo');
  $r->route('/bar')->to(action => 'bar');

  # Match
  my $m = Mojolicious::Routes::Match->new(GET => '/bar');
  $m->match($r);
  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 routes endpoint that actually matched.

root

  my $root = $m->root;
  $m       = $m->root($routes);

The root of the routes 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 ones.

new

  my $m = Mojolicious::Routes::Match->new(get => '/foo');
  my $m = Mojolicious::Routes::Match->new(get => '/foo', $ws);

Construct a new match object.

match

  $m->match(Mojolicious::Routes->new, Mojolicious::Controller->new);

Match against a routes 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.

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us.