From ad3ea7312254dfdd3d0f2724bd4ec7fc1cbe89ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Guti=C3=A9rrez?= Date: Wed, 29 Nov 2017 00:43:05 +0100 Subject: [PATCH] exception creation after OPTIONS check --- src/HttpExceptionManager.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/HttpExceptionManager.php b/src/HttpExceptionManager.php index f9e3710..8ac2312 100644 --- a/src/HttpExceptionManager.php +++ b/src/HttpExceptionManager.php @@ -171,10 +171,6 @@ public function notAllowedHandler( ResponseInterface $response, array $methods = [] ): ResponseInterface { - $exception = HttpExceptionFactory::methodNotAllowed( - sprintf('Method %s not allowed. Must be one of: %s', $request->getMethod(), implode(', ', $methods)) - ); - if ($request->getMethod() === RequestMethodInterface::METHOD_OPTIONS) { $optionsResponse = new Response(StatusCodeInterface::STATUS_OK); $optionsResponse->getBody()->write(sprintf('Allowed methods: %s', implode(', ', $methods))); @@ -183,6 +179,10 @@ public function notAllowedHandler( ->withHeader('Content-Type', 'text/plain; charset=utf-8'); } + $exception = HttpExceptionFactory::methodNotAllowed( + sprintf('Method %s not allowed. Must be one of: %s', $request->getMethod(), implode(', ', $methods)) + ); + return $this->handleHttpException($request, $response, $exception); }