Skip to content

Commit 4d4afd5

Browse files
committed
Fix #76
1 parent 3794f5d commit 4d4afd5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/ControllerInvoker.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __invoke(
3636
): ResponseInterface {
3737
// Inject the request and response by parameter name
3838
$parameters = [
39-
'request' => $request,
39+
'request' => self::injectRouteArguments($request, $routeArguments),
4040
'response' => $response,
4141
];
4242
// Inject the route arguments by name
@@ -46,4 +46,13 @@ public function __invoke(
4646

4747
return $this->invoker->call($callable, $parameters);
4848
}
49+
50+
private static function injectRouteArguments(ServerRequestInterface $request, array $routeArguments): ServerRequestInterface
51+
{
52+
$requestWithArgs = $request;
53+
foreach ($routeArguments as $key => $value) {
54+
$requestWithArgs = $requestWithArgs->withAttribute($key, $value);
55+
}
56+
return $requestWithArgs;
57+
}
4958
}

0 commit comments

Comments
 (0)