We're trying to make our REST API a bit more friendly, We have a base class for our REST API which inherits from Catalyst::Controller::REST. Each REST class can identify the query parameters it accepts. We thought it would be nice to make this information public and put this into the base class:
sub doc : Regex('/doc$') {
my ( $self, $c ) = @_;
$c->stash->{params} = $c->forward('allowed_query_params');
}
And from there, every REST url could have /doc/ added to the end to show which query parameters it accepts.
It doesn't work. $self is always a PIPs::C::API::V1::Franchise instance, no matter which URL is called. This appears to be because of these:
[26 Feb 2009 15:07:40,509] [Catalyst.Dispatcher] [DEBUG] Loaded Private actions:
.-----------------------+--------------------------------------+--------------.
| Private | Class | Method |
+-----------------------+--------------------------------------+--------------+
...
| /api/v1/franchise/doc | PIPs::C::Api::V1::Franchise | doc |
And:
[26 Feb 2009 15:07:40,514] [Catalyst.DispatchType.Regex] [DEBUG] Loaded Regex actions:
.--------------------------------------+--------------------------------------.
| Regex | Private |
+--------------------------------------+--------------------------------------+
| /doc$ | /api/v1/franchise/doc |
| /doc$ | /api/v1/version/doc |
| /doc$ | /api/v1/creditrole/doc |
| /doc$ | /api/v1/doc |
| /doc$ | /api/v1/segmentevent/doc |
| /doc$ | /api/v1/collection/doc |
| /doc$ | /api/v1/episode/doc |
So the very first instance of the "doc" method dispatches through Franchise, even if the controller for a given URL would be API::V1::Version or something like that.
How can I work around this? LocalRegex doesn't work, obviously, and chained actions don't seem appropriate because, due to the nature of our app, we never know how many path parts will be between '/api/v1/' and '/doc/'.
What am I missing?