Skip to content

Commit b7d1d41

Browse files
authored
fix(http): register request interface as singleton as soon as possible (#1379)
1 parent 5091fb6 commit b7d1d41

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

packages/router/src/GenericRouter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function dispatch(Request|PsrRequest $request): Response
3939
$request = map($request)->with(PsrRequestToGenericRequestMapper::class)->do();
4040
}
4141

42+
$this->container->singleton(Request::class, fn () => $request);
43+
4244
$callable = $this->getCallable();
4345

4446
return $this->processResponse($callable($request));

packages/router/src/MatchRouteMiddleware.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function __invoke(Request $request, HttpMiddlewareCallable $next): Respon
4343
// We register this newly created request object in the container
4444
// This makes it so that RequestInitializer is bypassed entirely when the controller action needs the request class
4545
// Making it so that we don't need to set any $_SERVER variables and stuff like that
46-
$this->container->singleton(Request::class, fn () => $request);
4746
$this->container->singleton($request::class, fn () => $request);
4847

4948
return $next($request);

0 commit comments

Comments
 (0)