named route not working after upgrade from 7.33

23 views
Skip to first unread message

Rolf Schaufelberger

unread,
Jan 9, 2020, 5:17:12 PM1/9/20
to Mojolicious
Hi, 
 I have a route definition like this

my $order = $r->any('/order')->to(controller => 'order');
$order->get('/')->to(action => 'index');
$order->post('/find')->to(action => 'find');
$order->get('/edit/:id')->to(action => 'index');
$order->get('/edit/:id(*tab)')->to(action => 'index', title => 'Auftrag bearbeiten')->name('order_edit');

in Order::find I then have :
...
return $self->redirect_to('order_edit', id => $order->id) if $order;

which works fine in 7.33

After upgrading to 8.29 it doesn't work any more, instead I get

[Mojolicious::Routes ] Routing to controller "Eller::Controller::Order" and action "find" [Mojolicious::Controller ] 302 Found (0.089613s, 11.159/s) [Mojolicious ] GET "/order/edit/243"

Changing my routes to:

my $order = $r->any('/order')->to(controller => 'order');
$order->get('/')->to(action => 'index');
$order->post('/find')->to(action => 'find');
$order->get('/edit/:id')->to(action => 'index')->name('order_edit');
$order->get('/edit/:id(*tab)')->to(action => 'index', title => 'Auftrag bearbeiten');

again works, yet, this isn't exactly the same.
I couldn't find any hints in the release notes, that sth. has changed for the routing.

"routes -v" gives
+/order .... * order ^\/order +/ .... GET ^/?(?:\.([^/]+))?$ +/find .... POST find ^\/find/?(?:\.([^/]+))?$ +/edit/:id .... GET editid ^\/edit/([^/.]+)/?(?:\.([^/]+))?$ +/edit/:id(*tab) .... GET "order_edit" ^\/edit/([^/.]+)/?(?:\.([^/]+))?$

for both 7.33 and 8.29

Any idea?
Rolf

Dan Book

unread,
Jan 9, 2020, 5:22:09 PM1/9/20
to mojol...@googlegroups.com
Placeholder syntax was changed from parentheses to chevrons <> in 7.75. I will add this to https://github.com/mojolicious/mojo/wiki/Upgrading once I figure out when the old syntax was actually removed.

-Dan

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/66b70122-cd26-4d14-8127-f4421526212b%40googlegroups.com.

Dan Book

unread,
Jan 9, 2020, 5:31:08 PM1/9/20
to mojol...@googlegroups.com

Francesc Guasch

unread,
Jan 10, 2020, 3:07:56 AM1/10/20
to mojol...@googlegroups.com
On 9/1/20 23:21, Dan Book wrote:
> Placeholder syntax was changed from parentheses to chevrons <> in 7.75. I will
> add this to https://github.com/mojolicious/mojo/wiki/Upgrading once I figure
> out when the old syntax was actually removed.
>

I too stumbled upon this and I did this to keep the old behaviour:

my $routes = app->routes->children;
for my $route (@$routes){
$route->pattern->quote_start('(');
$route->pattern->quote_end(')');
$route->pattern->parse($route->pattern->unparsed);
}

Reply all
Reply to author
Forward
0 new messages