eee
This commit is contained in:
+15
-15
@@ -46,7 +46,7 @@ class OnRequest implements OnRequestInterface
|
||||
/**
|
||||
* @var ResponseEmitterInterface
|
||||
*/
|
||||
public ResponseEmitterInterface $emitter;
|
||||
public ResponseEmitterInterface $responseEmitter;
|
||||
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ class OnRequest implements OnRequestInterface
|
||||
}
|
||||
$this->exception = $container->get($exception);
|
||||
$this->router = $container->get(DataGrip::class)->get(ROUTER_TYPE_HTTP);
|
||||
$this->emitter = $this->response->emmit;
|
||||
$this->responseEmitter = $this->response->emmit;
|
||||
$this->constrictResponse = $container->get(ConstrictResponse::class);
|
||||
$this->middlewareManager = $container->get(MiddlewareManager::class);
|
||||
}
|
||||
@@ -98,21 +98,17 @@ class OnRequest implements OnRequestInterface
|
||||
{
|
||||
try {
|
||||
/** @var ConstrictRequest $PsrRequest */
|
||||
$PsrRequest = Context::set(RequestInterface::class, $this->constrictRequest($request));
|
||||
$PsrRequest = Context::set(RequestInterface::class, $this->createConstrictRequest($request));
|
||||
|
||||
/** @var ConstrictResponse $PsrResponse */
|
||||
$PsrResponse = Context::set(ResponseInterface::class, new ConstrictResponse());
|
||||
$PsrResponse->withContentType($this->response->contentType);
|
||||
|
||||
/** @var $dispatcher */
|
||||
$dispatcher = $this->router->query($request->server['path_info'], $request->getMethod());
|
||||
Context::set(ResponseInterface::class, new ConstrictResponse())->withContentType($this->response->contentType);
|
||||
|
||||
/** @var $PsrResponse */
|
||||
$PsrResponse = $dispatcher->run($PsrRequest);
|
||||
$PsrResponse = $this->router->query($request->server['path_info'], $request->getMethod())->run($PsrRequest);
|
||||
} catch (Throwable $throwable) {
|
||||
$PsrResponse = $this->exception->emit($throwable, $this->constrictResponse);
|
||||
} finally {
|
||||
$this->emitter->sender($PsrResponse, $response, $PsrRequest);
|
||||
$this->responseEmitter->xxxxxxxxxxxxxxxxxxxxxxxxxSender($PsrResponse, $response, $PsrRequest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,11 +117,14 @@ class OnRequest implements OnRequestInterface
|
||||
* @param Request $request
|
||||
* @return ConstrictRequest
|
||||
*/
|
||||
protected function constrictRequest(Request $request): ConstrictRequest
|
||||
protected function createConstrictRequest(Request $request): ConstrictRequest
|
||||
{
|
||||
return (new ConstrictRequest())->withHeaders($request->header ?? [])->withUri(new Uri($request))
|
||||
->withProtocolVersion($request->server['server_protocol'])->withCookieParams($request->cookie ?? [])
|
||||
->withServerParams($request->server)->withQueryParams($request->get ?? [])
|
||||
return (new ConstrictRequest())->withHeaders($request->header ?? [])
|
||||
->withUri(new Uri($request))
|
||||
->withProtocolVersion($request->server['server_protocol'])
|
||||
->withCookieParams($request->cookie ?? [])
|
||||
->withServerParams($request->server)
|
||||
->withQueryParams($request->get ?? [])
|
||||
->withParsedBody(function () use ($request) {
|
||||
$contentType = $request->header['content-type'] ?? 'application/json';
|
||||
if (\str_contains($contentType, 'json')) {
|
||||
@@ -135,7 +134,8 @@ class OnRequest implements OnRequestInterface
|
||||
} else {
|
||||
return $request->post ?? [];
|
||||
}
|
||||
})->withUploadedFiles($request->files ?? [])
|
||||
})
|
||||
->withUploadedFiles($request->files ?? [])
|
||||
->withMethod($request->getMethod());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user