Problem with routing in Mojolicious > 5.15

33 views
Skip to first unread message

Александр Грошев

unread,
Aug 1, 2014, 9:09:56 AM8/1/14
to mojol...@googlegroups.com
Hi.

I have problem with routing in Mojolicious > 5.15.

  my $r = $self->routes;
  $r->get('/tags/:tag.rss')->to('router#tags_tag_rss');
  $r->get('/tags/:tag')->to('router#tags_tag');

In M 5.15
% ./script/mojo_twist routes --verbose
...
/tags/:tag.rss                ....  GET  tagstagrss             ^/tags/([^\/\.]+)\.rss(?:\.([^/]+)$)?
/tags/:tag                    ....  GET  tagstag                ^/tags/([^\/\.]+)(?:\.([^/]+)$)?

In M 5.16
% ./script/mojo_twist routes --verbose
...
/tags/:tag.rss                ....  GET  tagstagrss             ^/tags/([^\/\.]+)(?:\.([^/]+)$)?
/tags/:tag                    ....  GET  tagstag                ^/tags/([^\/\.]+)(?:\.([^/]+)$)?

I think this happened after Mojolicious::Routes::Pattern::_tokenize has been changed

I tried to fix my problem with:
1. $r->get('/tags/:tag', format => 'rss')->to('router#tags_tag_rss');
routes --verbose
/tags/:tag                    .C..  GET  tagstag                ^/tags/([^\/\.]+)(?:\.([^/]+)$)?

2. $r->get('/tags/:tag', tag => qr/rss$/)->to('router#tags_tag_rss');

routes --verbose
/tags/:tag                    .C..  GET  tagstag                ^/tags/([^\/\.]+)(?:\.([^/]+)$)?

None of these solutions work. App always trying call router#tags_tag.

How to fix a problem with routing if this behavior is normal?

sri

unread,
Aug 1, 2014, 9:45:12 AM8/1/14
to mojol...@googlegroups.com
  $r->get('/tags/:tag.rss')->to('router#tags_tag_rss');

$r->get('/tags/(:tag).rss')->to('router#tags_tag_rss');

--
sebastian 

aleksander.groschev

unread,
Aug 1, 2014, 9:49:01 AM8/1/14
to mojol...@googlegroups.com
Thanks. This solution fixed my problem.
/tags/(:tag).rss              ....  GET  tagstagrss             ^/tags/([^/\.]+)\.rss                     ^/?(?:\.([^/]+))?$
--
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 post to this group, send email to mojol...@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages