Commit 13c0d96f authored by Emiliano Balbuena's avatar Emiliano Balbuena

(chore): Short-circuit pre-PSR7 router

1 merge request!342WIP: (feat): Modernize Router (&75)
Pipeline #93894016 failed with stages
in 4 minutes and 33 seconds
......@@ -39,13 +39,13 @@ class Router
); // TODO: Ensure it works with reverse proxy
$response = $dispatcher
->pipe(new Kernel\CorsMiddleware())
->pipe(new Kernel\ContentNegotiationMiddleware())
->pipe(new Kernel\ErrorHandlerMiddleware())
->pipe(
(new Kernel\RouteResolverMiddleware())
->setAttributeName('_request-handler')
)
) // Note: Pre-PSR7 routes will not advance further than this
->pipe(new Kernel\CorsMiddleware())
->pipe(new Kernel\JsonPayloadMiddleware())
->pipe(new Kernel\FrameSecurityMiddleware())
->pipe(
......
......@@ -77,22 +77,16 @@ class RouteResolverMiddleware implements MiddlewareInterface
// Pre PSR-7 Controllers
if ($prePsr7Fallback->shouldRoute($request->getUri()->getPath())) {
return $handler
->handle(
$request
->withAttribute($this->attributeName, [$prePsr7Fallback, 'handle'])
)
return $prePsr7Fallback
->handle($request)
->withHeader('X-Route-Resolver', 'pre-psr7');
}
// Static HTML
if ($request->getAttribute('accept') === 'html') {
return $handler
->handle(
$request
->withAttribute($this->attributeName, [$prePsr7Fallback, 'handleStatic'])
)
return $prePsr7Fallback
->handleStatic($request)
->withHeader('X-Route-Resolver', 'pre-psr7-static');
}
......
Please register or to comment