/** * {@inheritdoc} */ public function perform(ServerRequestInterface $request, ResponseInterface $response, ContainerInterface $container) { $pipeline = new MiddlewarePipeline($container, $this->middlewares); return $pipeline->target($this->createEndpoint($container))->run($request, $response); }
/** * Pass request thought all http middlewares to appropriate endpoint. Default endpoint will be * used as fallback. Can thrown an exception happen in internal code. * * @param ServerRequestInterface $request * @param ResponseInterface $response * @return ResponseInterface * @throws HttpException */ public function perform(ServerRequestInterface $request, ResponseInterface $response = null) { $response = !empty($response) ? $response : $this->response(); $endpoint = $this->endpoint(); if (empty($endpoint)) { throw new HttpException("Unable to execute request without destination endpoint."); } $pipeline = new MiddlewarePipeline($this->middlewares, $this->container); $benchmark = $this->benchmark('request', $request->getUri()); try { //Exceptions (including client one) must be handled by pipeline return $pipeline->target($endpoint)->run($request, $response); } finally { $this->benchmark($benchmark); } }
/** * {@inheritdoc} */ public function perform(Request $request, Response $response) { if (empty($this->container)) { throw new RouteException("Unable to perform route endpoint without given container"); } $pipeline = new MiddlewarePipeline($this->middlewares, $this->container); return $pipeline->target($this->createEndpoint())->run($request, $response); }