final class MiddlewarePipeline implements RequestHandlerInterface (View source)

Executes an ordered PSR-15 middleware chain before a terminal request handler.

Methods

__construct(array $stack, RequestHandlerInterface $fallback, int $index = 0)

Creates one immutable cursor within the shared middleware sequence.

create(array $stack, RequestHandlerInterface $fallback)

Normalizes a middleware sequence and returns its initial execution cursor.

ResponseInterface
handle(ServerRequestInterface $request)

Invokes the current middleware or the terminal handler after the sequence is exhausted.

ResponseInterface

Details

__construct

__construct(array $stack, RequestHandlerInterface $fallback, int $index = 0)

Creates one immutable cursor within the shared middleware sequence.

Parameters

array $stack
RequestHandlerInterface $fallback
int $index

Exceptions

InvalidArgumentException

create

static MiddlewarePipeline create(array $stack, RequestHandlerInterface $fallback)

Normalizes a middleware sequence and returns its initial execution cursor.

Parameters

array $stack
RequestHandlerInterface $fallback

Return Value

MiddlewarePipeline

handle

ResponseInterface handle(ServerRequestInterface $request)

Invokes the current middleware or the terminal handler after the sequence is exhausted.

Parameters

ServerRequestInterface $request

Return Value

ResponseInterface