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