| 1 | package Mojolicious::Routes::Match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 21 | ▶ | use Mojo::Base -base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 21 | ▶ | use Mojo::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 21 | has [qw(endpoint root)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 21 | has position => 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 141 | ▶ | has stack => sub { [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 289 | ▶ | sub find { $_[0]->_match($_[0]->root, $_[1], $_[2]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 150 | ▶ | sub path_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path_for: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 150 | my ($self, $name, %values) = (shift, Mojo::Util::_options(@_)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # Current route | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 150 | ▶ | my ($route, $current) = (undef, !$name || $name eq 'current'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
!$name || $name eq 'current'
MC/DC100%2/2
!$name || $name eq 'current'
!$name
$name eq 'current'
Truth table100%3/3
not(A) || B
A= !$nameB= $name eq 'current'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 150 | ▶ | if ($current) { return {} unless $route = $self->endpoint } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # Find endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 18 | ▶ | else { return {path => $name} unless $route = $self->root->lookup($name) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Merge values (clear format) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 142 | ▶ | my $captures = $self->stack->[-1] // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->stack->[-1] // {}
MC/DC100%1/1
$self->stack->[-1] // {}
$self->stack->[-1]
Truth table100%2/2
A
A= $self->stack->[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 142 | my %merged = (%$captures, format => undef, %values); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 142 | my $pattern = $route->pattern; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 142 | my $constraints = $pattern->constraints; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | $merged{format} = ($current ? $captures->{format} : undef) // $pattern->defaults->{format} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 142 | ▶ | if !exists $values{format} && $constraints->{format} && $constraints->{format} ne '1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition88%8/9
not exists $values{"format"} and $constraints->{"format"} and $constraints->{"format"} ne 1
not exists $values{"format"} and $constraints->{"format"}
($current ? $captures->{"format"} : undef) // $pattern->defaults->{"format"}
MC/DC0%0/3
not exists $values{"format"} and $constraints->{"format"} and $constraints->{"format"} ne 1
not exists $values{"format"}
$constraints->{"format"}
$constraints->{"format"} ne 1
MC/DC50%1/2
($current ? $captures->{"format"} : undef) // $pattern->defaults->{"format"}
($current ? $captures->{"format"} : undef)
$pattern->defaults->{"format"}
Truth table0%0/4
not(A) and B and C
A= not exists $values{"format"}B= $constraints->{"format"}C= $constraints->{"format"} ne 1
Truth table66%2/3
A // B
A= ($current ? $captures->{"format"} : undef)B= $pattern->defaults->{"format"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 142 | return {path => $route->render(\%merged), websocket => $route->has_websocket}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1153 | ▶ | sub _match { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match: called CC=25 SCAR=33.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1153 | my ($self, $r, $c, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # Pattern | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1153 | my $path = $options->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1153 | my $partial = $r->partial; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1153 | ▶ | my $detect = (my $endpoint = $r->is_endpoint) && !$partial; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
(my $endpoint = $r->is_endpoint) && !$partial
MC/DC100%2/2
(my $endpoint = $r->is_endpoint) && !$partial
(my $endpoint = $r->is_endpoint)
!$partial
Truth table100%3/3
A && not(B)
A= (my $endpoint = $r->is_endpoint)B= !$partial
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1153 | ▶ | return undef unless my $captures = $r->pattern->match_partial(\$path, $detect); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 821 | local $options->{path} = $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 821 | ▶ | local @{$self->{captures} //= {}}{keys %$captures} = values %$captures; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"captures"} //= {}
MC/DC100%1/1
$self->{"captures"} //= {}
$self->{"captures"}
Truth table100%2/2
A
A= $self->{"captures"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 821 | $captures = $self->{captures}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # Method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 821 | my $methods = $r->methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 821 | ▶ | return undef if $methods && !grep { $_ eq $options->{method} } @$methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$methods and not grep({$_ eq $options->{"method"};} @$methods)
MC/DC100%2/2
$methods and not grep({$_ eq $options->{"method"};} @$methods)
$methods
not grep({$_ eq $options->{"method"};} @$methods)
Truth table100%3/3
A and not(B)
A= $methodsB= not grep({$_ eq $options->{"method"};} @$methods)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # Conditions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 792 | ▶ | if (my $over = $r->requires) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my $conditions = $self->{conditions} ||= $self->root->conditions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"conditions"} ||= $self->root->conditions
MC/DC0%0/2
$self->{"conditions"} ||= $self->root->conditions
$self->{"conditions"}
$self->root->conditions
Truth table0%0/3
A ||= B
A= $self->{"conditions"}B= $self->root->conditions
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | for (my $i = 0; $i < @$over; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | return undef unless my $condition = $conditions->{$over->[$i]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | return undef if !$condition->($r, $c, $captures, $over->[$i + 1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # WebSocket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 792 | ▶ | return undef if $r->is_websocket && !$options->{websocket}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$r->is_websocket and not $options->{"websocket"}
MC/DC100%2/2
$r->is_websocket and not $options->{"websocket"}
$r->is_websocket
not $options->{"websocket"}
Truth table100%3/3
A and not(B)
A= $r->is_websocketB= not $options->{"websocket"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # Partial | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 791 | ▶ | my $empty = !length $path || $path eq '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
!length($path) || $path eq '/'
MC/DC100%2/2
!length($path) || $path eq '/'
!length($path)
$path eq '/'
Truth table100%3/3
not(A) || B
A= !length($path)B= $path eq '/'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 791 | ▶ | if ($partial) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | $captures->{path} = $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | $self->endpoint($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | $empty = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # Endpoint (or intermediate destination) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 791 | ▶ | if (($endpoint && $empty) || $r->inline) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$endpoint and $empty or $r->inline
$endpoint and $empty
MC/DC100%3/3
$endpoint and $empty or $r->inline
$endpoint
$empty
$r->inline
Truth table80%4/5
A and B or C
A= $endpointB= $emptyC= $r->inline
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 237 | push @{$self->stack}, {%$captures}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 237 | ▶ | if ($endpoint && $empty) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$endpoint and $empty
MC/DC50%1/2
$endpoint and $empty
$endpoint
$empty
Truth table66%2/3
A and B
A= $endpointB= $empty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 214 | my $format = $captures->{format}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 214 | ▶ | if ($format) { $_->{format} = $format for @{$self->stack} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 214 | return !!$self->endpoint($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 23 | delete @$captures{qw(app cb)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # Match children | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 577 | ▶ | my $snapshot = $r->parent ? [@{$self->stack}] : []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 577 | for my $child (@{$r->_candidates($path)}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 864 | ▶ | return 1 if $self->_match($child, $c, $options); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 586 | $self->stack([@$snapshot]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 21 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | Mojolicious::Routes::Match - Find routes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | use Mojolicious::Controller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | use Mojolicious::Routes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | use Mojolicious::Routes::Match; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # Routes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | my $r = Mojolicious::Routes->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | $r->get('/user/:id'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | $r->put('/user/:id'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # Match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | my $c = Mojolicious::Controller->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | my $match = Mojolicious::Routes::Match->new(root => $r); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | $match->find($c => {method => 'PUT', path => '/user/23'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | say $match->stack->[0]{id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # Render | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | say $match->path_for->{path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | say $match->path_for(id => 24)->{path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | L<Mojolicious::Routes::Match> finds routes in L<Mojolicious::Routes> structures. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | L<Mojolicious::Routes::Match> implements the following attributes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | =head2 endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | my $route = $match->endpoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | $match = $match->endpoint(Mojolicious::Routes::Route->new); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | The route endpoint that matched, usually a L<Mojolicious::Routes::Route> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | =head2 position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | my $position = $match->position; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | $match = $match->position(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | Current position on the L</"stack">, defaults to C<0>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | =head2 root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | my $root = $match->root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | $match = $match->root(Mojolicious::Routes->new); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | The root of the route structure, usually a L<Mojolicious::Routes> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =head2 stack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | my $stack = $match->stack; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | $match = $match->stack([{action => 'foo'}, {action => 'bar'}]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | Captured parameters with nesting history. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | L<Mojolicious::Routes::Match> inherits all methods from L<Mojo::Base> and implements the following new ones. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | =head2 find | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | $match->find(Mojolicious::Controller->new, {method => 'GET', path => '/'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | Match controller and options against L</"root"> to find an appropriate L</"endpoint">. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | =head2 path_for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | my $info = $match->path_for; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | my $info = $match->path_for(foo => 'bar'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | my $info = $match->path_for({foo => 'bar'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | my $info = $match->path_for('named'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | my $info = $match->path_for('named', foo => 'bar'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | my $info = $match->path_for('named', {foo => 'bar'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | Render matching route with parameters into path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||