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