NAME

Plack::Middleware::HttpMethodTunnel - Tunnel HTTP methods over GET and POST.

SYNOPSIS

use Plack::Builder;

my $app = sub {
   return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Foo' ] ];
};

builder {
   enable "Plack::Middleware::HttpMethodTunnel";
   $app;
};

# X-HTTP-Method: DELETE

DESCRIPTION

HTML Forms don't allow HTTP methods other than POST or GET. While many of us use XmlHttpRequest these days (which does support DELETE and PUT), that's not always feasible or desired for every application. Therefore if you want to build a RESTful web app, or RESTful web services, and you want to provide an alternate way to specify those methods, this module is the answer.

All you need to do, is enable this middleware in your app. Then when making your request do one of theree things:

HTTP Header

Specifiy an HTTP Header:

X-HTTP-Method: DELETE
Query Param

Specify a query param:

/some/page?X-HTTP-Method=HEAD
Post Body Param

Specify a post body param via a hidden field:

<form method="POST">
   <input type="hidden" name="X-HTTP-Method" value="PUT">
</form>

CAVEATS

Only GET and HEAD may be tunneled over a GET request. All other methods must be tunneled over a POST.

If you specified both an HTTP header and a request param, the HTTP header will take precidence.

SUPPORT

Repository

http://github.com/rizen/Plack-Middleware-HttpMethodTunnel

Bug Reports

http://github.com/rizen/Plack-Middleware-HttpMethodTunnel/issues

SEE ALSO

Much of the implementation details for this were stolen from REST::Application.

AUTHOR

JT Smith <jt_at_plainblack_dot_com>

LEGAL

Ouch is Copyright 2011 Plain Black Corporation (http://www.plainblack.com) and is licensed under the same terms as Perl itself.