mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-02-14 01:30:19 +00:00
404 error handler for less app output pollution
Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
parent
fbffdeed9f
commit
769d5e9344
1 changed files with 9 additions and 0 deletions
|
|
@ -212,4 +212,13 @@ $app->get('/', function (\Psr\Http\Message\RequestInterface $request, Response $
|
|||
|
||||
$errorMiddleware = $app->addErrorMiddleware(false, true, true);
|
||||
|
||||
// Set a custom Not Found handler, which doesn't pollute the app output with 404 errors.
|
||||
$errorMiddleware->setErrorHandler(
|
||||
\Slim\Exception\HttpNotFoundException::class,
|
||||
function (Request $request, Throwable $exception, bool $displayErrorDetails) use ($app) {
|
||||
$response = $app->getResponseFactory()->createResponse();
|
||||
$response->getBody()->write('Not Found');
|
||||
return $response->withStatus(404);
|
||||
});
|
||||
|
||||
$app->run();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue