Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
no need for separate log messages
  • Loading branch information
kraih committed Jun 9, 2013
1 parent ed7f63e commit e72030f
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions lib/Mojolicious/Routes.pm
Expand Up @@ -163,17 +163,18 @@ sub _controller {
}

# Action
elsif (my $method = $self->_method($c, $field)) {
$log->debug(qq{Routing to controller "$class" and action "$method".});
elsif (my $method = $field->{action}) {
if (!$self->is_hidden($method)) {

# Try to call action
if (my $sub = $app->can($method)) {
$c->stash->{'mojo.routed'}++ unless $nested;
$continue = $app->$sub;
}
$log->debug(qq{Routing to controller "$class" and action "$method".});
if (my $sub = $app->can($method)) {
$c->stash->{'mojo.routed'}++ unless $nested;
$continue = $app->$sub;
}

# Action not found
else { $log->debug('Action not found in controller.') }
else { $log->debug('Action not found in controller.') }
}
else { $log->debug(qq{Action "$method" is not allowed.}) }
}

return !$nested || $continue ? 1 : undef;
Expand All @@ -191,21 +192,6 @@ sub _load {
return ++$self->{loaded}{$app};
}

sub _method {
my ($self, $c, $field) = @_;

# Hidden
return undef unless my $method = $field->{action};
$c->app->log->debug(qq{Action "$method" is not allowed.}) and return undef
if $self->is_hidden($method);

# Invalid
$c->app->log->debug(qq{Action "$method" is invalid.}) and return undef
unless $method =~ /^[a-zA-Z0-9_]+$/;

return $method;
}

sub _walk {
my ($self, $c) = @_;

Expand Down

0 comments on commit e72030f

Please sign in to comment.