user966588
user966588

Reputation:

how to use __PACKAGE__->config namespace in catalyst

__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

Answers (1)

daxim
daxim

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. So package MyApp::Controller::Example; would normally use example as its namespace for matching, but if this is specially overridden with __PACKAGE__->config( namespace => 'thing' );, it matches using the namespace thing instead.

Upvotes: 3

Related Questions