2017 © Pedro Peláez
 

library method-override

Middleware to override the request method using the X-Http-Method-Override header

image

middlewares/method-override

Middleware to override the request method using the X-Http-Method-Override header

  • Wednesday, January 24, 2018
  • by oscarotero
  • Repository
  • 2 Watchers
  • 2 Stars
  • 684 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 20 % Grown

The README.md

middlewares/method-override

Latest Version on Packagist ![Software License][ico-license] Testing ![Total Downloads][ico-downloads], (*1)

Middleware to override the request method using the X-Http-Method-Override header. This is useful for clients unable to send other methods than GET and POST., (*2)

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/method-override., (*3)

composer require middlewares/method-override

Example

Dispatcher::run([
    (new Middlewares\MethodOverride())
        ->getMethods(['HEAD', 'CONNECT', 'TRACE', 'OPTIONS'])
        ->postMethods(['PATCH', 'PUT', 'DELETE', 'COPY', 'LOCK', 'UNLOCK'])
        ->queryParameter('method')
        ->parsedBodyParameter('method')
]);

Usage

In the constructor you can provide a Psr\Http\Message\ResponseFactoryInterface to create the error response (405). If it's not defined, Middleware\Utils\Factory will be used to detect it automatically., (*4)

$responseFactory = new MyOwnResponseFactory();

$override = new Middlewares\MethodOverride($responseFactory);

getMethods

Allows to define the methods that can override the GET method. By default is ['HEAD', 'CONNECT', 'TRACE', 'OPTIONS']., (*5)

//The GET method can be overrided only with HEAD and CONNECT
$override = (new Middlewares\MethodOverride())->getMethods(['HEAD', 'CONNECT']);

postMethods

Array with the methods that can override the POST method. By default is ['PATCH', 'PUT', 'DELETE', 'COPY', 'LOCK', 'UNLOCK']., (*6)

//The POST method can be overrided only with DELETE and PUT 
$override = (new Middlewares\MethodOverride())->getMethods(['DELETE', 'PUT']);

queryParameter

Allows to use a query parameter in addition to the X-Http-Method-Override in GET requests. For example http://example.com/view/23?method=HEAD, (*7)

//The method can be override with ?new_method=OPTIONS
$override = (new Middlewares\MethodOverride())->queryParameter('new_method');

parsedBodyParameter

Allows to use a parsed body parameter in addition to the X-Http-Method-Override in POST., (*8)


Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details., (*9)

The MIT License (MIT). Please see LICENSE for more information., (*10)

The Versions

24/01 2018

dev-master

9999999-dev https://github.com/middlewares/method-override

Middleware to override the request method using the X-Http-Method-Override header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

24/01 2018

v1.0.0

1.0.0.0 https://github.com/middlewares/method-override

Middleware to override the request method using the X-Http-Method-Override header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

13/11 2017

v0.5.0

0.5.0.0 https://github.com/middlewares/method-override

Middleware to override the request method using the X-Http-Method-Override header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

21/09 2017

v0.4.0

0.4.0.0 https://github.com/middlewares/method-override

Middleware to override the request method using the X-Http-Method-Override header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

26/12 2016

v0.3.0

0.3.0.0 https://github.com/middlewares/method-override

Middleware to override the request method using the X-Http-Method-Override header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

23/11 2016

v0.2.0

0.2.0.0 https://github.com/middlewares/method-override

Middleware to override the request method using the X-Http-Method-Override header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

01/10 2016

v0.1.1

0.1.1.0 https://github.com/middlewares/method-override

Middleware to override the request method using the X-Http-Method-Override header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

01/10 2016

v0.1.0

0.1.0.0 https://github.com/middlewares/method-override

Middleware to override the request method using the X-Http-Method-Override header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15