Skip to content

Commit

Permalink
endpoints are just routes
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 26, 2014
1 parent 1ef444e commit 4642a80
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/Mojolicious/Plugin/DefaultHelpers.pm
Expand Up @@ -72,8 +72,8 @@ sub _csrf_token {
}

sub _current_route {
return '' unless my $endpoint = shift->match->endpoint;
return @_ ? $endpoint->name eq shift : $endpoint->name;
return '' unless my $route = shift->match->endpoint;
return @_ ? $route->name eq shift : $route->name;
}

sub _delay {
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -158,8 +158,8 @@ sub template_for {
if $controller && $action;

# Try the route name if we don't have controller and action
return undef unless my $endpoint = $c->match->endpoint;
return $endpoint->name;
return undef unless my $route = $c->match->endpoint;
return $route->name;
}

sub template_handler {
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Routes.pm
Expand Up @@ -92,9 +92,9 @@ sub match {

# Check routes
$match->match($c => {method => $method, path => $path, websocket => $ws});
return unless my $endpoint = $match->endpoint;
return unless my $route = $match->endpoint;
$cache->set(
"$method:$path:$ws" => {endpoint => $endpoint, stack => $match->stack});
"$method:$path:$ws" => {endpoint => $route, stack => $match->stack});
}

sub route {
Expand Down
16 changes: 8 additions & 8 deletions lib/Mojolicious/Routes/Match.pm
Expand Up @@ -13,26 +13,26 @@ sub path_for {
my ($self, $name, %values) = (shift, Mojo::Util::_options(@_));

# Current route
my $endpoint;
my $route;
if ($name && $name eq 'current' || !$name) {
return {} unless $endpoint = $self->endpoint;
return {} unless $route = $self->endpoint;
}

# Find endpoint
else { return {path => $name} unless $endpoint = $self->root->lookup($name) }
else { return {path => $name} unless $route = $self->root->lookup($name) }

# Merge values (clear format)
my $captures = $self->stack->[-1] || {};
%values = (%$captures, format => undef, %values);
my $pattern = $endpoint->pattern;
my $pattern = $route->pattern;
$values{format}
//= defined $captures->{format}
? $captures->{format}
: $pattern->defaults->{format}
if $pattern->constraints->{format};
my $path = $endpoint->render('', \%values);
return {path => $path, websocket => $endpoint->has_websocket};
my $path = $route->render('', \%values);
return {path => $path, websocket => $route->has_websocket};
}
sub _match {
Expand Down Expand Up @@ -144,8 +144,8 @@ Current position on the L</"stack">, defaults to C<0>.
=head2 endpoint
my $endpoint = $match->endpoint;
$match = $match->endpoint(Mojolicious::Routes::Route->new);
my $route = $match->endpoint;
$match = $match->endpoint(Mojolicious::Routes::Route->new);
The route endpoint that matched, usually a L<Mojolicious::Routes::Route>
object.
Expand Down

0 comments on commit 4642a80

Please sign in to comment.