GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PLACK::MIDDLEWARE::METHODOVERRIDE (3)

.ds Aq ’

Name

Plack::Middleware::MethodOverride - Override REST methods to Plack apps via POST

CONTENTS

Version

version 0.15

Synopsis

In your Plack app:



  use Plack::Builder;
  builder {
      enable MethodOverride;
      $app;
  };



PUT via a query parameter in your POST forms:



  <form method="POST" action="/foo?x-tunneled-method=PUT">
    <!-- ... -->
  </form>



Or override it via the X-HTTP-Method-Override header in a request:



  my $req = HTTP::Request->new(POST => /foo, [
      X-HTTP-Method-Override => PUT
  ]);



Description

Writing REST <http://en.wikipedia.org/wiki/Representational_State_Transfer>ful apps is a good thing, but if you’re also trying to support web browsers, it would be nice not to be reduced to GET and POST for everything.

This middleware allows for POST requests that pretend to be something else: by adding either a header named X-HTTP-Method-Override to the request, or a query parameter named x-tunneled-method to the URI, the client can say what method it actually meant. That is, as long as it meant one of these:
o GET
o POST
o HEAD
o PUT
o DELETE
o OPTIONS
o TRACE
o CONNECT
o PATCH
If so, then the REQUEST_METHOD in the PSGI environment will be replaced with the client’s desired value. The original request method is always stored under the plack.original_request_method key.

Configuration

These are the named arguments you can pass to new. Or, more likely, on the enable line in your builder block, as in



   enable MethodOverride, header => X-HTTP-Method, param => my_method;



CWheader

Specifies the HTTP header name which specifies the overriding HTTP method.

Defaults to X-HTTP-Method-Override, as used by Google for its APIs.

CWparam

Specifies the query parameter name to specify the overriding HTTP method.

Defaults to x-tunneled-method.

Acknowledgements

This module gleefully steals from Catalyst::TraitFor::Request::REST::ForBrowsers by Dave Rolsky and the original version by Tatsuhiko Miyagawa (which in turn stole from HTTP::Engine::Middleware::MethodOverride). Thanks to Aristotle Pagaltzis <http://plasmasturm.org/> for the shove in this direction, to Matt S Trout <http://www.trout.me.uk/> for suggesting that it be implemented as middleware, and to Hans Dieter Pearcey <http://www.weftsoar.net/> for convincing me not to parse body parameters.

Authors

o Tatsuhiko Miyagawa <miyagawa@bulknews.net>
o David E. Wheeler <david@justatheory.com>
o Aristotle Pagaltzis <pagaltzis@gmx.de>

Copyright and License

This software is copyright (c) 2015 by Tatsuhiko Miyagawa, David E. Wheeler, Aristotle Pagaltzis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 PLACK::MIDDLEWARE::METHODOVERRIDE (3) 2015-08-15

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.