Middleware that applies a map function to the request before passing to
the next handler.

@param RequestHandlerBase $requestHandler

@return callable
973616
public static function applyRequestHandler(RequestHandlerBase $requestHandler): callable
    {
        return function (callable $handler) use ($requestHandler) {
            return function ($request, array $options) use ($handler, $requestHandler) {
                return $handler($requestHandler->execute($request), $options);
            };
        };
    }
887202
public function handler(RouteHandlerInterface $handler)
    {
        $this->_method('before', [$handler, 'before']);
        $this->_method('wrap', [$handler, 'wrap']);
        $this->_method('after', [$handler, 'after']);

        return $this;
    }
71889
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $this->migration_service
            ->updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', Webtrees::SCHEMA_VERSION);

        return $handler->handle($request);
    }
1260470
private static function createMiddlewareFromClosure(Closure $handler): MiddlewareInterface
    {
        return new class($handler) implements MiddlewareInterface {
            private $handler;

            public function __construct(Closure $handler)
            {
                $this->handler = $handler;
            }

            public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
            {
                return call_user_func($this->handler, $request, $next);
            }
        };
    }
1052695
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        /* @var \Swoft\Http\Server\Parser\RequestParserInterface $requestParser */
        $requestParser = App::getBean('requestParser');
        $request       = $requestParser->parse($request);

        return $handler->handle($request);
    }
428392
public function getSupportingHandler(Request $request): AbstractRequestHandler
    {
        foreach ($this->requestHandlers as $requestHandler) {
            if ($requestHandler->supportsApplication($request) && $requestHandler->supportsRequest($request)) {
                return $requestHandler;
            }
        }

        throw new MissingRequestHandlerException();
    }
904370
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $requestPath = $this->getNormalizedPath($request);

        foreach ($this->middlewares as $pathPrefix => $middleware) {
            if (strpos($requestPath, $pathPrefix) === 0) {
                return $handler->handle(
                    $this->unprefixedRequest($request, $pathPrefix)
                        ->withAttribute($this->attribute, $middleware)
                );
            }
        }

        if ($this->continueOnError) {
            return $handler->handle($request);
        }

        return $this->responseFactory->createResponse(404);
    }
1005490
protected function handleRequest(Closure $handler, ?RequestInterface $request): ResponseInterface
    {
        $response = call_user_func($handler, $request);

        return $response;
    }
1326661
public function setHandler(MultiResponseHandlerInterface $handler = null):MultiRequest {

		if(!$handler){

			if(!class_exists($this->options->handler)){
				throw new RequestException('no handler set');
			}

			$handler = new $this->options->handler($this);

			if(!is_a($handler, MultiResponseHandlerInterface::class)){
				throw new RequestException('handler is not a MultiResponseHandlerInterface');
			}

		}

		$this->multiResponseHandler = $handler;

		return $this;
	}
1272599
final protected function next(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
        if ($this->_next) {
            return $this->_next->process($request, $handler);
        }
        return $handler->handle($request);
    }
1266605
public static function forRequest(Request $request, RequestHandler $handler, string $message = ''): self
    {
        return new static(
            sprintf(
                'The request [%s] could not be handled by [%s].  %s',
                $request::schema()->getId()->toString(),
                get_class($handler),
                $message
            ),
            Code::INTERNAL
        );
    }
1015856
protected function setLogHandler(\GuzzleHttp\HandlerStack $handlerStack, callable $logHandler)
    {
        try {
            $handlerStack->after('history', $logHandler, 'logger');
        } catch (\InvalidArgumentException $e) {
            try {
                $handlerStack->before('allow_redirects', $logHandler, 'logger');
            } catch (\InvalidArgumentException $e) {
                $handlerStack->push($logHandler, 'logger');
            }
        }

        return $this;
    }
390593
public function process(RequestInterface $request, HandlerInterface $handler)
    {
        $middleware = $this->callback;

        return $middleware($request, $handler);
    }
4570
private function createRequestHandler(RequestHandlerInterface $requestHandler)
    {
        return function (\swoole_http_request $swooleRequest, \swoole_http_response $swooleResponse) use ($requestHandler) {
            $request = $this->messageTransformer->transform($swooleRequest);
            $response = $requestHandler->handle($request);
            $this->messageTransformer->reverseTransform($response, $swooleResponse);

            $requestHandler->finish($request, $response);
        };
    }
188288
@Deprecated
    public void addRequestHandler(RequestHandler requestHandler) {
        checkMutability();
        requestHandler2s.add(RequestHandler2.adapt(requestHandler));
    }
1366657
protected function normalizeErrorHandler(callable $errorHandler)
    {
        if ($errorHandler instanceof ErrorHandler) {
            return $errorHandler;
        }

        $legacyResponseGenerator = function (
            $e,
            ServerRequestInterface $request,
            ResponseInterface $response
        ) use ($errorHandler) {
            return $errorHandler($request, $response, $e);
        };

        $errorHandler = new ErrorHandler(new Response(), $legacyResponseGenerator);
        return $errorHandler;
    }
712379
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        return $this->pipeline->withRequest($request, function () use ($request, $handler): ResponseInterface {
            return $handler->handle($request);
        });
    }