Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Added standard phpDoc, changed namespace, changed class name
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmoussa committed Dec 15, 2015
1 parent a63bb4b commit 21a91b0
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/BodyParamsMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
<?php
namespace Mwop;
/**
* @see http://github.com/zendframework/zend-expressive for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
*/

class BodyParams
namespace Zend\Expressive\Helper;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

class BodyParamsMiddleware
{
/**
* List of request methods that do not have any defined body semantics, and thus
* will not have the body parsed.
*
* @see https://tools.ietf.org/html/rfc7231
*
* @var array
*/
private $nonBodyRequests = [
'GET',
'HEAD',
'OPTIONS',
];

public function __invoke($request, $response, $next)
/**
* Adds JSON decoded request body to the request, where appropriate.
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable $next
*
* @return ResponseInterface
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
{
if (in_array($request->getMethod(), $this->nonBodyRequests)) {
return $next($request, $response);
Expand Down

0 comments on commit 21a91b0

Please sign in to comment.