Skip to content

Instantly share code, notes, and snippets.

@phluks
Last active Dec 20, 2015
Embed
What would you like to do?
Tripping up the mojo router
I seem to be doing something that trips up the mojo router.
The intention is to make a service structured like this:
<url>/<app>/<controller>/
Apparantly the code "works". So I assume Im doing doing the Mojo-thing wrong. I suspect its easy to
spot the mistake in the "Setup" section.
The symptoms:
Routes sometimes work and sometimes don't.
More precisely. The about the 3. or 4.th route getting hit cannot be routed to the controller.
Restarting the server will enable the same route if its hit early and disabling another route.
The testsuite exercises all the Modules and passes all tests.
The setup:
Mojo is run as cgi under apache2.
The routes are routed this way
The main router - BIER::SERVICES is a: Mojo::Base 'Mojolicious';
It routes to Fejl in 'startup' with:
my $r = $self->routes;
$r->route('/fejl')->detour('fejl#'); #<host>/fejl/*
The BIER::SERVICES::Fejl module is a Mojo::Base 'Mojolicious'
It routes to the controllers in 'startup' with:
my $r = $self->routes;
my $fejl = $r->route(); # was previously 'waypoint('/')' #<host>/fejl/*
$fejl->get('/updates')->to('updates#list'); #<host>/fejl/updates/
The BIER::SERVICES::Fejl::Updates is a Mojo::Base 'Mojolicious::Controller'
It has the 'list' method
The log:
# After some successes - Mojo cant find the Updates controller
[Mon Jul 29 09:58:30 2013] [debug] GET "/fejl/updates/".
[Mon Jul 29 09:58:30 2013] [debug] Routing to application "BIER::SERVICES::Fejl".
[Mon Jul 29 09:58:30 2013] [debug] Controller "BIER::SERVICES::Fejl::Updates" does not exist.
[Mon Jul 29 09:58:30 2013] [debug] Template "updates/list.html.ep" not found.
[Mon Jul 29 09:58:30 2013] [error] Not found: https://<host>/activity
[Mon Jul 29 09:58:30 2013] [debug] 200 OK (0.014928s, 66.988/s).
# server restart - now Mojo finds it
==> backend-7016-error.log <==
[Mon Jul 29 09:58:47 2013] [notice] Apache/2.2.15 (Unix) mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Mon Jul 29 09:58:49 2013] [debug] GET "/fejl/updates/".
[Mon Jul 29 09:58:49 2013] [debug] Routing to application "BIER::SERVICES::Fejl".
[Mon Jul 29 09:58:49 2013] [debug] Routing to controller "BIER::SERVICES::Fejl::Updates" and action "list".
[Mon Jul 29 09:58:49 2013] [debug] 200 OK (0.039930s, 25.044/s).
The routes:
./bierservices.cgi routes -v
/perldoc/*module * perldocmodule ^/perldoc(?:/(.+)?)?(?:\.([^/]+)$)?
/ * ^(?:\.([^/]+)$)?
/debug * debug ^/debug(?:\.([^/]+)$)?
/activity * activity ^/activity(?:\.([^/]+)$)?
/fejl * fejl ^/fejl(?:\.([^/]+)$)?
Versions:
./bierservices.cgi version
CORE
Perl (v5.10.1, linux)
Mojolicious (4.14, Top Hat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment