[Catalyst] REST - like uri design for CRUD

Dave Rolsky autarch at urth.org
Mon Jan 21 00:09:59 GMT 2008


On Sun, 20 Jan 2008, Thomas L. Shinnick wrote:

> They specifically allow that when PUT is not available or impracticable 
> (clients, firewalls, and proxies can get in the way), you could 'overload' 
> POST by, for example, adding a query parameter "_method=PUT" to pass-thru the 
> real request method.  The idea is that the handler would pick off this 
> parameter and dispatch as though the HTTP method had really been PUT.  But 
> you try to use this request like you would a 'real' PUT, in what the data 
> contains and how it is used.
>
> But this is a question I have, whether the REST dispatching modules have an 
> capability like this, interpreting overloaded POSTs?

I added this to a custom Catalyst::Request subclass I use for my app. It 
looks like this:

  sub method
  {
      my $self = shift;

      return $self->NEXT::method(@_)
          if @_;

      return $self->{__method} if $self->{__method};

      my $method = $self->NEXT::method();

      return $method unless $method && uc $method eq 'POST';

      my $tunneled = $self->param('x-tunneled-method');

      return $self->{__method} = $tunneled ? $tunneled : $method;
  }


-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/



More information about the Catalyst mailing list