[Catalyst] REST - like uri design for CRUD
Christopher Laco
claco at chrislaco.com
Mon Jan 21 00:16:01 GMT 2008
Dave Rolsky wrote:
> 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=3DPUT" 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 =3D shift;
> =
> return $self->NEXT::method(@_)
> if @_;
> =
> return $self->{__method} if $self->{__method};
> =
> my $method =3D $self->NEXT::method();
> =
> return $method unless $method && uc $method eq 'POST';
> =
> my $tunneled =3D $self->param('x-tunneled-method');
> =
> return $self->{__method} =3D $tunneled ? $tunneled : $method;
> }
> =
> =
> -dave
Here's my hack against my REST controller subclass of C::Controller::REST:
> if ($c->request->method eq 'POST' && $c->request->param('_method')) {
> $c->request->method(uc $c->request->param('_method'));
> };
Since the REST package already has a Request subclass, I didn't really =
want to make yet another one...esp if the SOAP stuff also gets loaded.
-=3DChris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080120/5431=
1e4f/signature.pgp
More information about the Catalyst
mailing list