2016-04-10 02:38:07 -05:00
|
|
|
<?php
|
2017-10-12 03:13:20 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-09-20 13:27:34 -05:00
|
|
|
namespace Shlinkio\Shlink;
|
|
|
|
|
2017-04-13 02:43:11 -05:00
|
|
|
use Zend\Expressive;
|
2017-03-24 15:10:25 -05:00
|
|
|
use Zend\Stratigility\Middleware\ErrorHandler;
|
2016-04-10 02:38:07 -05:00
|
|
|
|
|
|
|
return [
|
2016-04-17 12:34:16 -05:00
|
|
|
|
2016-04-10 02:38:07 -05:00
|
|
|
'middleware_pipeline' => [
|
2017-03-24 15:10:25 -05:00
|
|
|
'pre-routing' => [
|
2018-11-24 05:49:25 -06:00
|
|
|
'middleware' => (function () {
|
|
|
|
$middleware = [
|
|
|
|
ErrorHandler::class,
|
|
|
|
Expressive\Helper\ContentLengthMiddleware::class,
|
|
|
|
];
|
|
|
|
|
|
|
|
if (Common\Exec\ExecutionContext::currentContextIsSwoole()) {
|
|
|
|
$middleware[] = Common\Middleware\CloseDbConnectionMiddleware::class;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $middleware;
|
|
|
|
})(),
|
2018-09-20 13:27:34 -05:00
|
|
|
'priority' => 12,
|
2017-03-24 15:10:25 -05:00
|
|
|
],
|
|
|
|
'pre-routing-rest' => [
|
2018-04-07 01:31:03 -05:00
|
|
|
'path' => '/rest',
|
2017-03-24 15:10:25 -05:00
|
|
|
'middleware' => [
|
2018-09-20 13:27:34 -05:00
|
|
|
Rest\Middleware\PathVersionMiddleware::class,
|
|
|
|
Rest\Middleware\ShortUrl\ShortCodePathMiddleware::class,
|
2017-03-24 15:10:25 -05:00
|
|
|
],
|
|
|
|
'priority' => 11,
|
|
|
|
],
|
|
|
|
|
2016-04-10 02:38:07 -05:00
|
|
|
'routing' => [
|
|
|
|
'middleware' => [
|
2018-03-20 19:05:55 -05:00
|
|
|
Expressive\Router\Middleware\RouteMiddleware::class,
|
2016-07-03 01:40:39 -05:00
|
|
|
],
|
|
|
|
'priority' => 10,
|
|
|
|
],
|
|
|
|
|
2017-03-24 15:10:25 -05:00
|
|
|
'rest' => [
|
|
|
|
'path' => '/rest',
|
|
|
|
'middleware' => [
|
2018-09-20 13:27:34 -05:00
|
|
|
Rest\Middleware\CrossDomainMiddleware::class,
|
2018-03-20 18:46:26 -05:00
|
|
|
Expressive\Router\Middleware\ImplicitOptionsMiddleware::class,
|
2018-09-20 13:27:34 -05:00
|
|
|
Rest\Middleware\BodyParserMiddleware::class,
|
2018-09-24 12:24:23 -05:00
|
|
|
Rest\Middleware\AuthenticationMiddleware::class,
|
2017-03-24 15:10:25 -05:00
|
|
|
],
|
|
|
|
'priority' => 5,
|
|
|
|
],
|
|
|
|
|
2016-07-03 01:40:39 -05:00
|
|
|
'post-routing' => [
|
|
|
|
'middleware' => [
|
2018-03-20 19:05:55 -05:00
|
|
|
Expressive\Router\Middleware\DispatchMiddleware::class,
|
2018-11-18 13:13:38 -06:00
|
|
|
|
|
|
|
// Only if a not found error is triggered, set-up the locale to be used
|
|
|
|
Common\Middleware\LocaleMiddleware::class,
|
2018-09-20 13:27:34 -05:00
|
|
|
Core\Response\NotFoundHandler::class,
|
2016-04-10 02:38:07 -05:00
|
|
|
],
|
|
|
|
'priority' => 1,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|