Mojolicious::Plugin::MethodOverride - Simulate HTTP Verbs
Version 0.001
package My::App; use Mojo::Base 'Mojolicious'; sub startup { my $self = shift; $self->plugin('MethodOverride'); ... } 1;
This plugin can simulate any HTTP verb (a.k.a. HTTP method) in environments where HTTP verbs other than GET and POST are not available. It uses the same approach as in many other restful web frameworks, where it replaces the HTTP POST method with a method given by an HTTP header. It is also possible to define a query parameter for the same purpose.
HTTP POST
HTTP
A valid value for the HTTP verb in the header or query parameter is one of:
It must be specified in UPPER case.
The default HTTP header to override the HTTP POST method is "X-HTTP-Method-Override". Overriding through a query parameter is off by default.
"X-HTTP-Method-Override"
These settings can be changed in the plugin method call as demonstrated in the examples below:
# Mojolicious $self->plugin( MethodOverride => { header => 'X-Tunneled-Method', param => 'x-tunneled-method', } ); # Mojolicious::Lite plugin 'MethodOverride', header => 'X-HTTP-Method', param => 'http_method';
HTTP header can be disabled by setting to undef:
undef
# A Mojolicious app, that enables method overriding # by query parameter only: $self->plugin( MethodOverride => { header => undef, param => 'x-tunneled-method', } );
Bernhard Graf <graf at cpan.org>
<graf at cpan.org>
Please report any bugs or feature requests to bug-mojolicious-plugin-methodoverride at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mojolicious-Plugin-MethodOverride. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-mojolicious-plugin-methodoverride at rt.cpan.org
Plack::Middleware::MethodOverride, Catalyst::TraitFor::Request::REST::ForBrowsers, HTTP::Engine::Middleware::MethodOverride, http://code.google.com/apis/gdata/docs/2.0/basics.html
Copyright 2011 Bernhard Graf.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Mojolicious::Plugin::MethodOverride, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::MethodOverride
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::MethodOverride
For more information on module installation, please visit the detailed CPAN module installation guide.