[Catalyst] Catalyst::Action::REST

Adam Jacob adam at stalecoffee.org
Mon Nov 20 17:27:51 GMT 2006


On Mon, Nov 20, 2006 at 10:43:39AM -0600, Jonathan Rockway wrote:
> It just occurred to me (after reading Aristotle's post below), that it
> might be a good idea to provide verbs for dumb HTTP clients (web
> browsers).  Example:
> 
>    sub foo :Local :ActionClass('REST') {}
>    sub foo_DELETE {}
> 
> This would create URIs:
> 
> foo
> foo/delete
> 
> so that a GET (or POST, which might be better in this case) request to
> foo/delete would do the same thing as a real DELETE request.  This means
> that your AJAX and smart HTTP clients could do a DELETE /foo/bar, but
> you could still have a link in the browser to /foo/delete/bar.

Wel, since most of the content you are sending is serialized, browsing
it with Firefox just isn't particularly useful out of the box.  If it
was me, I would probably just roll an interface that called my service
and did the right thing behind the scenes.  

Patches to turn that on with a config option would be neat, though.
Doesn't feel very RESTful. :)

> Also, is it currently possible to do something like this?
> 
>    sub foo :Local :ActionClass('REST'){
>      my ($self, $c) = @_
>      do_something_before_method_specific_action();
>      $self->next::method(@_);
>      do_something_after_method_specific_action();
>    }
> 
> As always, thanks for writing this.  I look forward to using it for
> something ;)

No.  The "real" sub foo only gets called if we don't have a more
specific sub that matches, and it pre-populates the 405 response.  

Adam




More information about the Catalyst mailing list