Skip to content

Commit

Permalink
Merge pull request #336 from sanderdlm/add-route-attribute-to-request
Browse files Browse the repository at this point in the history
Save the matched Route object as an attribute on the request
  • Loading branch information
philipobenito authored Sep 28, 2024
2 parents 2664e0f + 67b98d3 commit b56a818
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function dispatchRequest(ServerRequestInterface $request): ResponseInterf
case FastRoute::FOUND:
$route = $this->ensureHandlerIsRoute($match[1], $method, $uri)->setVars($match[2]);

$request = $request->withAttribute('route', $route);

if ($this->isExtraConditionMatch($route, $request)) {
$this->setFoundMiddleware($route);
$request = $this->requestWithRouteAttributes($request, $route);
Expand Down

0 comments on commit b56a818

Please sign in to comment.