http://qs1969.pair.com?node_id=1206864

hesco has asked for the wisdom of the Perl Monks concerning the following question:

https://gist.github.com/hesco/84f60c9c7eb5e4e6725262cd854dda1e

I am seeing this log entry: "[debug] Controller "Vote::Controller::User::Login::User::Login" does not exist". However, it would find everything it needs, instead at this path: Vote::Controller::User::Login.

[Sun Jan 7 17:42:43 2018] [debug] GET "/cgi-bin/index" [Sun Jan 7 17:42:43 2018] [debug] Routing to a callback [Sun Jan 7 17:42:43 2018] [debug] [CGI:index:23229] START /opt/local/ +vote/vagrant/cf_vote/scripts/index [Sun Jan 7 17:42:45 2018] [debug] 200 OK (1.266254s, 0.790/s)

That worked fine.

[Sun Jan 7 17:42:50 2018] [debug] GET "/cgi-bin/login" [Sun Jan 7 17:42:50 2018] [debug] Routing to application "Vote::Contr +oller::User::Login" [Sun Jan 7 17:42:50 2018] [debug] Controller "Vote::Controller::User: +:Login::User::Login" does not exist

Expecting to seek, instead:
Vote::Controller::User::Login

[Sun Jan 7 17:42:50 2018] [debug] Rendering template "user/login/logi +n_dispatch.html.ep" [Sun Jan 7 17:42:50 2018] [debug] Rendering template "auth/login_page +.html.ep" [Sun Jan 7 17:42:50 2018] [debug] Rendering template "auth/login.html +.ep" [Sun Jan 7 17:42:50 2018] [debug] Rendering template "auth/password_r +eminder.html.ep" [Sun Jan 7 17:42:50 2018] [debug] Rendering template "auth/password_r +eset.html.ep" [Sun Jan 7 17:42:50 2018] [debug] Rendering template "auth/get_a_logi +n.html.ep" [Sun Jan 7 17:42:50 2018] [debug] Rendering template "layouts/default +.html.ep" [Sun Jan 7 17:42:50 2018] [debug] Rendering template "layouts/header. +html.ep" [Sun Jan 7 17:42:50 2018] [debug] Rendering template "auth/logout.htm +l.ep" [Sun Jan 7 17:42:50 2018] [debug] Rendering template "layouts/footer. +html.ep" [Sun Jan 7 17:42:50 2018] [debug] 200 OK (0.084435s, 11.843/s)

It found the intended templates, but unsupported by a useful controller, I am getting white screen of death in the browser.

package Vote; use lib qw( lib local/lib/perl5 ); use Mojo::Base 'Mojolicious'; use CGI; use Moose; use MooseX::NonMoose; # <snip other dependencies, several Moose-enabled attributes> sub startup { my $self = shift; my $log_file = 'VoteApp.log'; # <snip> $self->plugin('CGI', { support_semicolon_in_query_string => 1, route => '/cgi-bin/index', script => '/opt/local/vote/vagrant/cf_vote/scripts/index', errlog => $log_file, }); # and several additional routes to legacy 2006 era cgi scripts $r->any(['GET','POST'] => '/cgi-bin/login')->to( controller => 'user-login', action => 'login_dispatch', ); $r->any(['GET','POST'] => '/cgi-bin/password-reminder')->to( controller => 'user-login', action => 'login_dispatch', ); $self->plugin('CGI', { support_semicolon_in_query_string => 1, route => '/cgi-bin/admin', script => '/opt/local/vote/vagrant/cf_vote/scripts/admin', errlog => $log_file, }); # <snip> }

My question being: what is it I am missing about routing, which is causing this bug?

2018-01-09 Athanasius added code tags to log entry and linkified link

if( $lal && $lol ) { $life++; }
if( $insurance->rationing() ) { $people->die(); }

Replies are listed 'Best First'.
Re: Mojolicious Routing mangles controller path
by Laurent_R (Canon) on Jan 07, 2018 at 22:32 UTC
    Please use <code> and </code> tags for your log excerpts, as you do for your code.
Re: Mojolicious Routing mangles controller path
by Anonymous Monk on Jan 08, 2018 at 01:44 UTC
    As a guy whos only ever used lite, im wondering why youre specifying controllers , as in perl packages/modules, using strings with dashes -- Why map routes manualy and indirectly ? Thats neither convention nor convenience...

      Dashes are easier to type, especially for non-typists, and read better to non hackers—are also far less confusing when handwritten—so it's potentially a convenience for end users.

        Dashes are easier to type, especially for non-typists, and read better to non hackers—are also far less confusing when handwritten—so it's potentially a convenience for end users.

        Why would any of those non-OPs/non-programmers be involved in typing the name of controllers?

        Also what exactly does that have to do with the programmer OP whos having trouble getting mojo to call the correct controller (perl module)?

        Seems to me the most straight forward thing to do, since OP is already typing all this out, is to tell mojo in perl module terms what to call, not in shorthand terms