set full package name for controller in a route

23 views
Skip to first unread message

Miguel Prz

unread,
Jun 21, 2020, 12:35:50 PM6/21/20
to Mojolicious
I want to reuse a set of controllers of a different hierarchy (starting with MyOther) used by my application (MyApp::Controller). But when I set:

$app->routes->get('/init/:id')->to(controller =>"MyOther::Controller", action=> 'init' );

I get an error in run time: (...) Controller "MyApp::MyOther::Controller" does not exist

I don't know how to avoid the automatic "MyApp::" prefix

Thanks!

Dan Book

unread,
Jun 21, 2020, 12:38:19 PM6/21/20
to mojol...@googlegroups.com
You need to set it as the namespace for the route:  https://metacpan.org/pod/Mojolicious::Guides::Routing#Namespaces

-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/2abe60b0-ca69-4f87-9c6d-5a9b22d7e1cdo%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages