예제 #1
0
 /**
  * @param RequestHandlerInterface $requestHandler
  *
  * @return callable
  */
 private function createRequestHandler(RequestHandlerInterface $requestHandler)
 {
     return function (ReactRequest $reactRequest, ReactResponse $reactResponse) use($requestHandler) {
         $request = $this->messageTransformer->transform($reactRequest);
         $response = $requestHandler->handle($request);
         $this->messageTransformer->reverseTransform($response, $reactResponse);
         $requestHandler->finish($request, $response);
     };
 }
예제 #2
0
 /**
  * @param RequestHandlerInterface $requestHandler
  *
  * @return CallbackRequestHandler
  */
 private function decorateRequestHandler(RequestHandlerInterface $requestHandler)
 {
     return new CallbackRequestHandler(function (RequestInterface $request) use($requestHandler) {
         $ex = null;
         try {
             $response = $requestHandler->handle($request);
         } catch (\Exception $ex) {
             $response = $this->handleException($ex);
         }
         return isset($response) ? $response : $this->exceptionHandler->createErrorResponseByException($ex);
     }, function (RequestInterface $request, ResponseInterface $response) use($requestHandler) {
         try {
             $requestHandler->finish($request, $response);
         } catch (\Exception $ex) {
             $this->handleException($ex);
         }
     });
 }
 /**
  * {@inheritdoc}
  */
 public function handle(RequestInterface $request)
 {
     return $this->innerHandler->handle($request);
 }