| Current Path : /home/jeromecohp/www/templates/yootheme/packages/http-server/src/ |
| Current File : /home/jeromecohp/www/templates/yootheme/packages/http-server/src/BodyMiddleware.php |
<?php
namespace YOOtheme;
use YOOtheme\Http\Request;
use YOOtheme\Http\Response;
class BodyMiddleware
{
/**
* Handles JSON requests.
*
* @param Request $request
* @param callable $next
*
* @return Response
*/
public static function parseJson($request, callable $next)
{
if (stripos($request->getHeaderLine('Content-Type'), 'application/json') === 0) {
$request = $request->withParsedBody(json_decode((string) $request->getBody(), true));
}
return $next($request);
}
}