Skip to content

Commit

Permalink
Merge pull request #2978 from dlundgren/split-resolve-routing
Browse files Browse the repository at this point in the history
Split the routing results to its own function.
  • Loading branch information
l0gicgate committed Jul 1, 2020
2 parents 61093d9 + 14cbc75 commit 5f017b0
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Slim/Middleware/RoutingMiddleware.php
Expand Up @@ -72,10 +72,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
*/
public function performRouting(ServerRequestInterface $request): ServerRequestInterface
{
$routingResults = $this->routeResolver->computeRoutingResults(
$request->getUri()->getPath(),
$request->getMethod()
);
$routingResults = $this->resolveRoutingResultsFromRequest($request);
$routeStatus = $routingResults->getRouteStatus();

$request = $request->withAttribute(RouteContext::ROUTING_RESULTS, $routingResults);
Expand All @@ -101,4 +98,18 @@ public function performRouting(ServerRequestInterface $request): ServerRequestIn
throw new RuntimeException('An unexpected error occurred while performing routing.');
}
}

/**
* Resolves the route from the given request
*
* @param ServerRequestInterface $request
* @return RoutingResults
*/
protected function resolveRoutingResultsFromRequest(ServerRequestInterface $request): RoutingResults
{
return $this->routeResolver->computeRoutingResults(
$request->getUri()->getPath(),
$request->getMethod()
);
}
}

0 comments on commit 5f017b0

Please sign in to comment.