public __invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface | ||
$request | Psr\Http\Message\ServerRequestInterface | |
$response | Psr\Http\Message\ResponseInterface | |
$next | callable | |
Результат | Psr\Http\Message\ResponseInterface |
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
{
$method = $this->getOverrideMethod($request);
if (!empty($method) && $method !== $request->getMethod()) {
$allowed = $this->getAllowedOverrideMethods($request);
if (!empty($allowed)) {
if (in_array($method, $allowed)) {
$request = $request->withMethod($method);
} else {
return $response->withStatus(405);
}
}
}
return $next($request, $response);
}