Skip to content

Commit

Permalink
exception creation after OPTIONS check
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Nov 28, 2017
1 parent cbec43e commit ad3ea73
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/HttpExceptionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand All @@ -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);
}

Expand Down

0 comments on commit ad3ea73

Please sign in to comment.