The problem
I have been learning the Catalyst web framework and I am trying to understand how Catalyst dispatches URLs to application "actions".
It seems I can write my application with ambiguous URL dispatching rules:
package Myapp::Controller::Root {
__PACKAGE__->config(namespace => '');
....
sub foo :Local {
my ( $self, $c ) = @_;
$c->response->body('foo action in Root controller.');
}
}
package Myapp::Controller::Foo {
....
sub default :Path {
my ( $self, $c ) = @_;
$c->response->body('default action in Foo controller.');
}
}
These two actions are defined in different packages but both are associated with the '/foo/...' path. Looking at the above code, it's not clear which action will take precedence. That decision seems to be more or less made at random by Catalyst when the application is launched. Sometimes it is the former action, sometimes it's the latter.
Note that the above code is a contrived example and I probably wouldn't intentionally create two different actions that map to the same path. Nonetheless, I don't know how to predict which action will ultimately get called just by looking at the code.
The question
Is there a way to instruct Catalyst to disallow this kind of ambiguity or at least provide a warning?