[Catalyst] How to get default()-like behavior outside of the Root controller

Trevor Leffler tleffler at uw.edu
Fri Feb 6 22:51:13 GMT 2015


Some of my top-level controllers represent different, er... "major 
pieces" of my application.  They have, among other things, different 
default views, which are mainly just for configuring different page 
wrappers.  These controllers have this action pattern:

package MyApp::Admin;
sub base : Chained('/') : PathPart('admin') : CaptureArgs(0) { ... }
sub index : Chained('base') : PathPart('') : Args(0) { ... }

package MyApp::Survey;
sub base : Chained('/') : PathPart('survey') : CaptureArgs(0) { ... }
...etc...

Requests for non-extant paths fall through to Root->default(), which 
gives the (undesired) default root view.  I tried giving my top-level 
controllers their own default() methods, but as others have found [1], 
'default() : Path' has precedence over 'index : Chained'.  Otherwise, I 
get the appropriate view with 'Page Not Found' content for bad urls, 
e.g. /admin/blargh or /survey/123/nurgle

I am looking for suggestions/solutions to get the desired behavior.

Changing index() to 'index : Path' is not a viable option.


Thanks,
--Trevor

[1] http://www.gossamer-threads.com/lists/catalyst/users/24883



More information about the Catalyst mailing list