Hi all,

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.   Our various 
REST classes which inherit from this and each class can identify the query 
parameters it accepts.  So we thought it would be nice to 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 this:

  [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          
|

So the very first instance of the "doc" method dispatches through Franchise, 
even if the controller for a given URL would be API::V1::Warning 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? :)

Cheers,
Ovid
 --
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to