mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Updated system so that NotFoundDelegate is used
This commit is contained in:
parent
3dcc510da1
commit
6935b2ebe2
@ -2,6 +2,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Shlinkio\Shlink\Common\Middleware\LocaleMiddleware;
|
use Shlinkio\Shlink\Common\Middleware\LocaleMiddleware;
|
||||||
|
use Shlinkio\Shlink\Core\Response\NotFoundDelegate;
|
||||||
use Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware;
|
use Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware;
|
||||||
use Shlinkio\Shlink\Rest\Middleware\CheckAuthenticationMiddleware;
|
use Shlinkio\Shlink\Rest\Middleware\CheckAuthenticationMiddleware;
|
||||||
use Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware;
|
use Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware;
|
||||||
@ -48,7 +49,7 @@ return [
|
|||||||
'post-routing' => [
|
'post-routing' => [
|
||||||
'middleware' => [
|
'middleware' => [
|
||||||
Expressive\Router\Middleware\DispatchMiddleware::class,
|
Expressive\Router\Middleware\DispatchMiddleware::class,
|
||||||
Expressive\Handler\NotFoundHandler::class,
|
NotFoundDelegate::class,
|
||||||
],
|
],
|
||||||
'priority' => 1,
|
'priority' => 1,
|
||||||
],
|
],
|
||||||
|
@ -39,12 +39,12 @@ class NotFoundDelegate implements DelegateInterface
|
|||||||
*/
|
*/
|
||||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
public function handle(ServerRequestInterface $request): ResponseInterface
|
||||||
{
|
{
|
||||||
$accepts = explode(',', $request->getHeaderLine('Accept'));
|
$accepts = \explode(',', $request->getHeaderLine('Accept'));
|
||||||
$accept = array_shift($accepts);
|
$accept = \array_shift($accepts);
|
||||||
$status = StatusCodeInterface::STATUS_NOT_FOUND;
|
$status = StatusCodeInterface::STATUS_NOT_FOUND;
|
||||||
|
|
||||||
// If the first accepted type is json, return a json response
|
// If the first accepted type is json, return a json response
|
||||||
if (in_array($accept, ['application/json', 'text/json', 'application/x-json'], true)) {
|
if (\in_array($accept, ['application/json', 'text/json', 'application/x-json'], true)) {
|
||||||
return new Response\JsonResponse([
|
return new Response\JsonResponse([
|
||||||
'error' => 'NOT_FOUND',
|
'error' => 'NOT_FOUND',
|
||||||
'message' => 'Not found',
|
'message' => 'Not found',
|
||||||
|
Loading…
Reference in New Issue
Block a user