[Catalyst] Catalyst::Action::REST

John Napiorkowski jjn1056 at yahoo.com
Mon Nov 20 17:26:16 GMT 2006


--- Jonathan Rockway <jon at jrock.us> wrote:

> Adam Jacob wrote:
> > After much discussion, I've unleased
> Catalyst::Action::REST upon an
> > unsuspecting CPAN.  It's an attempt at making
> RESTful web applications
> > in Catalyst easier (they were already pretty
> easy.) The basics:
> > 
> > 1) Uses an Action class to extend Catalyst's
> dispatch mechanism to allow
> > for different methods based on the HTTP Method. 
> For example:
> > 
> > sub foo :Local :ActionClass('REST') {}
> > 
> > sub foo_GET {}
> > 
> > sub foo_POST {}
> > 
> > sub foo_DELETE {}
> 
> 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.

Some REST API providers use an HTTP line:

X-HTTP-Method-Override: ....

to deal with this issue.  This is very ontentiousin
the community however :)  

--john


> 
> (Maybe foo/arg0/.../argn/delete would look nicer
> than
> foo/delete/arg0/.../argn ?)
> 
> 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 ;)
> 
> -- 
> package JAPH;use Catalyst
> qw/-Debug/;($;=JAPH)->config(name => do {
> $,.=reverse qw[Jonathan tsu rehton lre rekca
> Rockway][$_].[split //,
> ";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;
> 
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo:
> http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
>
http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
> 



 
____________________________________________________________________________________
Sponsored Link

Compare mortgage rates for today. 
Get up to 5 free quotes. 
Www2.nextag.com



More information about the Catalyst mailing list