shlink/config/autoload/middleware-pipeline.global.php

83 lines
2.5 KiB
PHP
Raw Normal View History

2016-04-10 10:38:07 +03:00
<?php
2019-10-05 18:26:10 +03:00
2017-10-12 11:13:20 +03:00
declare(strict_types=1);
namespace Shlinkio\Shlink;
2020-01-01 23:11:53 +03:00
use Laminas\Stratigility\Middleware\ErrorHandler;
2020-04-08 18:27:26 +03:00
use Mezzio\Helper;
2020-01-01 23:11:53 +03:00
use Mezzio\ProblemDetails;
2020-04-08 18:27:26 +03:00
use Mezzio\Router;
use PhpMiddleware\RequestId\RequestIdMiddleware;
use RKA\Middleware\IpAddress;
2016-04-10 10:38:07 +03:00
2021-02-11 15:52:36 +03:00
use function extension_loaded;
2016-04-10 10:38:07 +03:00
return [
2016-04-17 20:34:16 +03:00
2016-04-10 10:38:07 +03:00
'middleware_pipeline' => [
'error-handler' => [
'middleware' => [
2021-02-11 15:52:36 +03:00
// For some reason, with swoole 4.6.3, piping this middleware makes requests to have incomplete body or
// never finish loading. Disabling it for swoole fixes it as it already calculates the header on itself
...extension_loaded('swoole') ? [] : [Helper\ContentLengthMiddleware::class],
ErrorHandler::class,
],
],
'error-handler-rest' => [
'path' => '/rest',
'middleware' => [
Rest\Middleware\CrossDomainMiddleware::class,
RequestIdMiddleware::class,
ProblemDetails\ProblemDetailsMiddleware::class,
],
],
'pre-routing' => [
'middleware' => [
Common\Middleware\CloseDbConnectionMiddleware::class,
],
],
2016-04-10 10:38:07 +03:00
'routing' => [
'middleware' => [
2020-04-08 18:27:26 +03:00
Router\Middleware\RouteMiddleware::class,
Router\Middleware\ImplicitHeadMiddleware::class,
],
],
'rest' => [
'path' => '/rest',
'middleware' => [
2020-04-08 18:27:26 +03:00
Router\Middleware\ImplicitOptionsMiddleware::class,
Rest\Middleware\BodyParserMiddleware::class,
Rest\Middleware\AuthenticationMiddleware::class,
],
],
'dispatch' => [
'middleware' => [
2020-04-08 18:27:26 +03:00
Router\Middleware\DispatchMiddleware::class,
],
],
'not-found-rest' => [
'path' => '/rest',
'middleware' => [
ProblemDetails\ProblemDetailsNotFoundHandler::class,
],
],
'not-found' => [
'middleware' => [
// This middleware is in front of tracking actions explicitly. Putting here for orphan visits tracking
IpAddress::class,
Core\ErrorHandler\NotFoundTypeResolverMiddleware::class,
Core\ErrorHandler\NotFoundTrackerMiddleware::class,
Core\ErrorHandler\NotFoundRedirectHandler::class,
Core\ErrorHandler\NotFoundTemplateHandler::class,
2016-04-10 10:38:07 +03:00
],
],
],
2020-04-08 18:27:26 +03:00
2016-04-10 10:38:07 +03:00
];