Added zend problem details to the project

This commit is contained in:
Alejandro Celaya
2019-11-22 19:49:14 +01:00
parent 4e5ab21a47
commit 74854b3dac
6 changed files with 49 additions and 46 deletions

View File

@@ -18,7 +18,6 @@ use Zend\Expressive\Template\TemplateRendererInterface;
use function array_shift;
use function explode;
use function Functional\contains;
use function rtrim;
class NotFoundHandler implements RequestHandlerInterface
@@ -64,14 +63,6 @@ class NotFoundHandler implements RequestHandlerInterface
$accept = array_shift($accepts);
$status = StatusCodeInterface::STATUS_NOT_FOUND;
// If the first accepted type is json, return a json response
if (contains(['application/json', 'text/json', 'application/x-json'], $accept)) {
return new Response\JsonResponse([
'error' => 'NOT_FOUND',
'message' => 'Not found',
], $status);
}
$template = $routeResult->isFailure() ? self::NOT_FOUND_TEMPLATE : self::INVALID_SHORT_CODE_TEMPLATE;
return new Response\HtmlResponse($this->renderer->render($template), $status);
}