Reputation:
__PACKAGE__->config(namespace => '');
I have seen this statement in Root Controller Root.pm
of my Catalyst application.
What I know about this is that, this statement is used to specify root controller.
Now I want to know is ,What else way is this statement used,
means Can I use this to specify other controller namespace? If yes,How?
Upvotes: 1
Views: 1064
Reputation: 39158
Both questions are explained in the manual. Read Actions in Catalyst::Manual::Intro
.
Application Wide Actions
[…] The code
__PACKAGE__->config( namespace => '' );
makes the controller act as if its namespace is empty. […] an empty namespace makes many of the URL-matching attributes, such as:Path
and:Local
match at the start of the URL path (i.e. the application root).
Overriding the namespace
Note that
__PACKAGE__->config->(namespace => ... )
can be used to override the current namespace when matching. Sopackage MyApp::Controller::Example;
would normally useexample
as its namespace for matching, but if this is specially overridden with__PACKAGE__->config( namespace => 'thing' );
, it matches using the namespacething
instead.
Upvotes: 3