mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Updated to expressive 2 and used new error handling system
This commit is contained in:
@@ -1,29 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "shlinkio/shlink",
|
"name": "shlinkio/shlink",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"homepage": "http://shlink.io",
|
"homepage": "https://shlink.io",
|
||||||
"description": "A self-hosted and PHP-based URL shortener application with CLI and REST interfaces",
|
"description": "A self-hosted and PHP-based URL shortener application with CLI and REST interfaces",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Alejandro Celaya Alastrué",
|
"name": "Alejandro Celaya Alastrué",
|
||||||
"homepage": "http://www.alejandrocelaya.com",
|
"homepage": "https://www.alejandrocelaya.com",
|
||||||
"email": "alejandro@alejandrocelaya.com"
|
"email": "alejandro@alejandrocelaya.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.6 || ^7.0",
|
"php": "^5.6 || ^7.0",
|
||||||
"zendframework/zend-expressive": "^1.0",
|
"zendframework/zend-expressive": "^2.0",
|
||||||
"zendframework/zend-expressive-fastroute": "^1.3",
|
"zendframework/zend-expressive-fastroute": "^2.0",
|
||||||
"zendframework/zend-expressive-twigrenderer": "^1.0",
|
"zendframework/zend-expressive-twigrenderer": "^1.4",
|
||||||
"zendframework/zend-stdlib": "^2.7",
|
"zendframework/zend-stdlib": "^3.0",
|
||||||
"zendframework/zend-servicemanager": "^3.0",
|
"zendframework/zend-servicemanager": "^3.0",
|
||||||
"zendframework/zend-paginator": "^2.6",
|
"zendframework/zend-paginator": "^2.6",
|
||||||
"zendframework/zend-config": "^2.6",
|
"zendframework/zend-config": "^3.0",
|
||||||
"zendframework/zend-i18n": "^2.7",
|
"zendframework/zend-i18n": "^2.7",
|
||||||
"zendframework/zend-config-aggregator": "^0.1",
|
"zendframework/zend-config-aggregator": "^0.1",
|
||||||
"acelaya/zsm-annotated-services": "^0.2.0",
|
"acelaya/zsm-annotated-services": "^1.0",
|
||||||
"acelaya/ze-content-based-error-handler": "^1.0",
|
"acelaya/ze-content-based-error-handler": "^2.0",
|
||||||
"doctrine/orm": "^2.5",
|
"doctrine/orm": "^2.5",
|
||||||
"guzzlehttp/guzzle": "^6.2",
|
"guzzlehttp/guzzle": "^6.2",
|
||||||
"symfony/console": "^3.0",
|
"symfony/console": "^3.0",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use Zend\Expressive\Container;
|
|||||||
use Zend\Expressive\Router;
|
use Zend\Expressive\Router;
|
||||||
use Zend\Expressive\Template;
|
use Zend\Expressive\Template;
|
||||||
use Zend\Expressive\Twig;
|
use Zend\Expressive\Twig;
|
||||||
|
use Zend\Stratigility\Middleware\ErrorHandler;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ return [
|
|||||||
Template\TemplateRendererInterface::class => Twig\TwigRendererFactory::class,
|
Template\TemplateRendererInterface::class => Twig\TwigRendererFactory::class,
|
||||||
\Twig_Environment::class => Twig\TwigEnvironmentFactory::class,
|
\Twig_Environment::class => Twig\TwigEnvironmentFactory::class,
|
||||||
Router\RouterInterface::class => Router\FastRouteRouterFactory::class,
|
Router\RouterInterface::class => Router\FastRouteRouterFactory::class,
|
||||||
|
ErrorHandler::class => Container\ErrorHandlerFactory::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
use Acelaya\ExpressiveErrorHandler\ErrorHandler\ContentBasedErrorHandler;
|
use Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory;
|
||||||
use Zend\Expressive\Container\WhoopsErrorHandlerFactory;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'dependencies' => [
|
'dependencies' => [
|
||||||
@@ -21,7 +20,7 @@ return [
|
|||||||
'error_handler' => [
|
'error_handler' => [
|
||||||
'plugins' => [
|
'plugins' => [
|
||||||
'factories' => [
|
'factories' => [
|
||||||
ContentBasedErrorHandler::DEFAULT_CONTENT => WhoopsErrorHandlerFactory::class,
|
'text/html' => WhoopsErrorResponseGeneratorFactory::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,9 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use Shlinkio\Shlink\Common\Middleware\LocaleMiddleware;
|
||||||
|
use Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware;
|
||||||
|
use Shlinkio\Shlink\Rest\Middleware\CheckAuthenticationMiddleware;
|
||||||
|
use Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware;
|
||||||
|
use Shlinkio\Shlink\Rest\Middleware\PathVersionMiddleware;
|
||||||
use Zend\Expressive\Container\ApplicationFactory;
|
use Zend\Expressive\Container\ApplicationFactory;
|
||||||
|
use Zend\Stratigility\Middleware\ErrorHandler;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
'middleware_pipeline' => [
|
'middleware_pipeline' => [
|
||||||
|
'pre-routing' => [
|
||||||
|
'middleware' => [
|
||||||
|
ErrorHandler::class,
|
||||||
|
LocaleMiddleware::class,
|
||||||
|
],
|
||||||
|
'priority' => 11,
|
||||||
|
],
|
||||||
|
'pre-routing-rest' => [
|
||||||
|
'path' => '/rest',
|
||||||
|
'middleware' => [
|
||||||
|
PathVersionMiddleware::class,
|
||||||
|
],
|
||||||
|
'priority' => 11,
|
||||||
|
],
|
||||||
|
|
||||||
'routing' => [
|
'routing' => [
|
||||||
'middleware' => [
|
'middleware' => [
|
||||||
ApplicationFactory::ROUTING_MIDDLEWARE,
|
ApplicationFactory::ROUTING_MIDDLEWARE,
|
||||||
@@ -11,6 +32,16 @@ return [
|
|||||||
'priority' => 10,
|
'priority' => 10,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'rest' => [
|
||||||
|
'path' => '/rest',
|
||||||
|
'middleware' => [
|
||||||
|
CrossDomainMiddleware::class,
|
||||||
|
BodyParserMiddleware::class,
|
||||||
|
CheckAuthenticationMiddleware::class,
|
||||||
|
],
|
||||||
|
'priority' => 5,
|
||||||
|
],
|
||||||
|
|
||||||
'post-routing' => [
|
'post-routing' => [
|
||||||
'middleware' => [
|
'middleware' => [
|
||||||
ApplicationFactory::DISPATCH_MIDDLEWARE,
|
ApplicationFactory::DISPATCH_MIDDLEWARE,
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
use Shlinkio\Shlink\Common\Middleware;
|
|
||||||
|
|
||||||
return [
|
|
||||||
|
|
||||||
'middleware_pipeline' => [
|
|
||||||
'pre-routing' => [
|
|
||||||
'middleware' => [
|
|
||||||
Middleware\LocaleMiddleware::class,
|
|
||||||
],
|
|
||||||
'priority' => 5,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -23,7 +23,6 @@ class ConfigProviderTest extends TestCase
|
|||||||
{
|
{
|
||||||
$config = $this->configProvider->__invoke();
|
$config = $this->configProvider->__invoke();
|
||||||
|
|
||||||
$this->assertArrayHasKey('middleware_pipeline', $config);
|
|
||||||
$this->assertArrayHasKey('dependencies', $config);
|
$this->assertArrayHasKey('dependencies', $config);
|
||||||
$this->assertArrayHasKey('twig', $config);
|
$this->assertArrayHasKey('twig', $config);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
use Shlinkio\Shlink\Rest\Middleware;
|
|
||||||
|
|
||||||
return [
|
|
||||||
|
|
||||||
'middleware_pipeline' => [
|
|
||||||
'pre-routing' => [
|
|
||||||
'path' => '/rest',
|
|
||||||
'middleware' => [
|
|
||||||
Middleware\PathVersionMiddleware::class,
|
|
||||||
],
|
|
||||||
'priority' => 11,
|
|
||||||
],
|
|
||||||
|
|
||||||
'rest' => [
|
|
||||||
'path' => '/rest',
|
|
||||||
'middleware' => [
|
|
||||||
Middleware\CrossDomainMiddleware::class,
|
|
||||||
Middleware\BodyParserMiddleware::class,
|
|
||||||
Middleware\CheckAuthenticationMiddleware::class,
|
|
||||||
],
|
|
||||||
'priority' => 5,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
@@ -24,7 +24,6 @@ class ConfigProviderTest extends TestCase
|
|||||||
$config = $this->configProvider->__invoke();
|
$config = $this->configProvider->__invoke();
|
||||||
|
|
||||||
$this->assertArrayHasKey('error_handler', $config);
|
$this->assertArrayHasKey('error_handler', $config);
|
||||||
$this->assertArrayHasKey('middleware_pipeline', $config);
|
|
||||||
$this->assertArrayHasKey('routes', $config);
|
$this->assertArrayHasKey('routes', $config);
|
||||||
$this->assertArrayHasKey('dependencies', $config);
|
$this->assertArrayHasKey('dependencies', $config);
|
||||||
$this->assertArrayHasKey('translator', $config);
|
$this->assertArrayHasKey('translator', $config);
|
||||||
|
|||||||
Reference in New Issue
Block a user