-
-
Save anonymous/ba23cb028c3eac379a95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojolicious/Routes.pm b/lib/Mojolicious/Routes.pm | |
index d7366d3..b9f5123 100644 | |
--- a/lib/Mojolicious/Routes.pm | |
+++ b/lib/Mojolicious/Routes.pm | |
@@ -97,9 +97,7 @@ sub match { | |
"$method:$path:$ws" => {endpoint => $route, stack => $match->stack}); | |
} | |
-sub route { | |
- shift->add_child(Mojolicious::Routes::Route->new(@_))->children->[-1]; | |
-} | |
+sub without_formats { !($_[0]->pattern->constraints->{format} = 0) and $_[0] } | |
sub _action { shift->plugins->emit_chain(around_action => @_) } | |
@@ -344,15 +342,11 @@ results for future lookups. | |
Match routes with L<Mojolicious::Routes::Match>. | |
-=head2 route | |
+=head2 without_formats | |
- my $route = $r->route; | |
- my $route = $r->route('/:action'); | |
- my $route = $r->route('/:action', action => qr/\w+/); | |
- my $route = $r->route(format => 0); | |
+ $r = $r->without_formats; | |
-Low-level generator for routes matching all HTTP request methods, returns a | |
-L<Mojolicious::Routes::Route> object. | |
+Disable format detection. | |
=head1 SEE ALSO | |
diff --git a/lib/Mojolicious/Routes/Route.pm b/lib/Mojolicious/Routes/Route.pm | |
index d1a3ceb..002b660 100644 | |
--- a/lib/Mojolicious/Routes/Route.pm | |
+++ b/lib/Mojolicious/Routes/Route.pm | |
@@ -122,7 +122,7 @@ sub root { shift->_chain->[0] } | |
sub route { | |
my $self = shift; | |
- my $route = $self->add_child($self->new(@_))->children->[-1]; | |
+ my $route = $self->add_child(__PACKAGE__->new(@_))->children->[-1]; | |
my $format = $self->pattern->constraints->{format}; | |
$route->pattern->constraints->{format} //= 0 if defined $format && !$format; | |
return $route; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment