src/Strategy/JsonStrategy.php
protected function buildJsonResponseMiddleware(HttpException $exception) : MiddlewareInterface
    {
        return new class($this->responseFactory->createResponse(), $exception) implements MiddlewareInterface
        {
            protected $response;
            protected $exception;

            public function __construct(ResponseInterface $response, HttpException $exception)
            {
                $this->response  = $response;
                $this->exception = $exception;
            }

            public function process(
                ServerRequestInterface $request,
                RequestHandlerInterface $requestHandler
            ) : ResponseInterface {
                return $this->exception->buildJsonResponse($this->response);
            }
        };
    }
protected function buildJsonResponseMiddleware(HttpException $exception) : MiddlewareInterface
    {
        return new class($this->responseFactory->createResponse(), $exception) implements MiddlewareInterface
        {
            protected $response;
            protected $exception;

            public function __construct(ResponseInterface $response, HttpException $exception)
            {
                $this->response  = $response;
                $this->exception = $exception;
            }

            public function process(
                ServerRequestInterface $request,
                RequestHandlerInterface $requestHandler
            ) : ResponseInterface {
                return $this->exception->buildJsonResponse($this->response);
            }
        };
    }
protected function buildJsonResponseMiddleware ( HttpException $ exception ) : MiddlewareInterface { return new class ( $ this -> responseFactory -> createResponse ( ) , $ exception ) implements MiddlewareInterface { protected $ response ; protected $ exception ; public function __construct ( ResponseInterface $ response , HttpException $ exception ) { $ this -> response = $ response ; $ this -> exception = $ exception ; } public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ requestHandler ) : ResponseInterface { return $ this -> exception -> buildJsonResponse ( $ this -> response ) ; } } ; }
Return a middleware the creates a JSON response from an HTTP exception

@param \League\Route\Http\Exception $exception

@return \Psr\Http\Server\MiddlewareInterface
Return a middleware the creates a JSON response from an HTTP exception