2016-04-10 09:38:07 +02:00
|
|
|
<?php
|
2019-10-05 17:26:10 +02:00
|
|
|
|
2017-10-12 10:13:20 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-09-20 20:27:34 +02:00
|
|
|
namespace Shlinkio\Shlink;
|
|
|
|
|
2020-01-01 21:11:53 +01:00
|
|
|
use Laminas\Stratigility\Middleware\ErrorHandler;
|
|
|
|
use Mezzio\ProblemDetails;
|
2020-04-08 17:27:26 +02:00
|
|
|
use Mezzio\Router;
|
2020-02-19 18:58:22 +01:00
|
|
|
use PhpMiddleware\RequestId\RequestIdMiddleware;
|
2021-02-09 17:28:06 +01:00
|
|
|
use RKA\Middleware\IpAddress;
|
2023-05-07 13:18:19 +02:00
|
|
|
use Shlinkio\Shlink\Common\Middleware\AccessLogMiddleware;
|
2021-02-12 09:24:13 +01:00
|
|
|
use Shlinkio\Shlink\Common\Middleware\ContentLengthMiddleware;
|
2021-02-11 13:52:36 +01:00
|
|
|
|
2016-04-10 09:38:07 +02:00
|
|
|
return [
|
2016-04-17 19:34:16 +02:00
|
|
|
|
2016-04-10 09:38:07 +02:00
|
|
|
'middleware_pipeline' => [
|
2019-11-22 18:01:38 +01:00
|
|
|
'error-handler' => [
|
2018-12-07 19:46:46 +01:00
|
|
|
'middleware' => [
|
2023-05-07 13:18:19 +02:00
|
|
|
AccessLogMiddleware::class,
|
2021-02-12 09:24:13 +01:00
|
|
|
ContentLengthMiddleware::class,
|
2021-12-19 10:23:55 +01:00
|
|
|
RequestIdMiddleware::class,
|
2018-12-07 19:46:46 +01:00
|
|
|
ErrorHandler::class,
|
2021-08-16 12:49:15 +02:00
|
|
|
Rest\Middleware\CrossDomainMiddleware::class,
|
2019-11-22 18:01:38 +01:00
|
|
|
],
|
|
|
|
],
|
2019-11-22 19:49:14 +01:00
|
|
|
'error-handler-rest' => [
|
|
|
|
'path' => '/rest',
|
|
|
|
'middleware' => [
|
|
|
|
ProblemDetails\ProblemDetailsMiddleware::class,
|
|
|
|
],
|
|
|
|
],
|
2019-11-22 18:01:38 +01:00
|
|
|
|
|
|
|
'pre-routing' => [
|
|
|
|
'middleware' => [
|
2018-12-07 19:46:46 +01:00
|
|
|
Common\Middleware\CloseDbConnectionMiddleware::class,
|
|
|
|
],
|
2017-03-24 21:10:25 +01:00
|
|
|
],
|
|
|
|
|
2016-04-10 09:38:07 +02:00
|
|
|
'routing' => [
|
|
|
|
'middleware' => [
|
2020-04-08 17:27:26 +02:00
|
|
|
Router\Middleware\RouteMiddleware::class,
|
|
|
|
Router\Middleware\ImplicitHeadMiddleware::class,
|
2016-07-03 08:40:39 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
|
2017-03-24 21:10:25 +01:00
|
|
|
'rest' => [
|
|
|
|
'path' => '/rest',
|
|
|
|
'middleware' => [
|
2022-08-13 17:48:55 +02:00
|
|
|
Rest\Middleware\ErrorHandler\BackwardsCompatibleProblemDetailsHandler::class,
|
2020-04-08 17:27:26 +02:00
|
|
|
Router\Middleware\ImplicitOptionsMiddleware::class,
|
2018-09-20 20:27:34 +02:00
|
|
|
Rest\Middleware\BodyParserMiddleware::class,
|
2018-09-24 19:24:23 +02:00
|
|
|
Rest\Middleware\AuthenticationMiddleware::class,
|
2017-03-24 21:10:25 +01:00
|
|
|
],
|
|
|
|
],
|
|
|
|
|
2019-11-22 19:49:14 +01:00
|
|
|
'dispatch' => [
|
2016-07-03 08:40:39 +02:00
|
|
|
'middleware' => [
|
2020-04-08 17:27:26 +02:00
|
|
|
Router\Middleware\DispatchMiddleware::class,
|
2019-11-22 19:49:14 +01:00
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
'not-found-rest' => [
|
|
|
|
'path' => '/rest',
|
|
|
|
'middleware' => [
|
|
|
|
ProblemDetails\ProblemDetailsNotFoundHandler::class,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'not-found' => [
|
|
|
|
'middleware' => [
|
2021-02-09 17:28:06 +01:00
|
|
|
// This middleware is in front of tracking actions explicitly. Putting here for orphan visits tracking
|
|
|
|
IpAddress::class,
|
2021-02-08 21:38:19 +01:00
|
|
|
Core\ErrorHandler\NotFoundTypeResolverMiddleware::class,
|
2021-07-15 16:54:54 +02:00
|
|
|
Core\ShortUrl\Middleware\ExtraPathRedirectMiddleware::class,
|
2021-02-08 21:38:19 +01:00
|
|
|
Core\ErrorHandler\NotFoundTrackerMiddleware::class,
|
2019-11-23 10:25:12 +01:00
|
|
|
Core\ErrorHandler\NotFoundRedirectHandler::class,
|
|
|
|
Core\ErrorHandler\NotFoundTemplateHandler::class,
|
2016-04-10 09:38:07 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
2020-04-08 17:27:26 +02:00
|
|
|
|
2016-04-10 09:38:07 +02:00
|
|
|
];
|