container = $container; $this->response = $response; $this->request = $request; } public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $params = $this->request->all(); /** * @var RequestService $requestService */ $requestService = $this->container->make(RequestService::class); $requestLog = $requestService->createRequestLog($this->request->getRequestUri(), $params); $ctxResponse = Context::get(ResponseInterface::class); $ctxResponse = $ctxResponse->withHeader('X-Request-Id', $requestLog->request_id); Context::set(ResponseInterface::class, $ctxResponse); Context::set('requestLog', $requestLog); $response = $handler->handle($request); $requestLog->response_data = (string)$response->getBody(); $requestLog->response_time = date('Y-m-d H:i:s'); return $response; } }