Raydium Framework

MiddlewareDispatcher
in package
implements RequestHandlerInterface

Interfaces, Classes, Traits and Enums

RequestHandlerInterface

Table of Contents

$container  : Container
$finalHandler  : RequestHandlerInterface
$logger  : LoggerInterface|null
$middlewareQueue  : array<string|int, mixed>
$middlewareRegistry  : MiddlewareRegistry
__construct()  : mixed
MiddlewareDispatcher constructor.
addMiddleware()  : void
Adds middleware to the queue.
handle()  : ResponseInterface
Handles the request by processing the middleware queue.
getNextHandler()  : static
Creates a new instance of MiddlewareDispatcher with the remaining middleware queue.

Properties

Methods

__construct()

MiddlewareDispatcher constructor.

public __construct(RequestHandlerInterface $finalHandler, Container $container, MiddlewareRegistry $middlewareRegistry[, null|LoggerInterface $logger = null ]) : mixed
Parameters
$finalHandler : RequestHandlerInterface

The final handler to invoke if no middleware processes the request.

$container : Container
$middlewareRegistry : MiddlewareRegistry
$logger : null|LoggerInterface = null

Optional logger to log any errors in middleware.

Return values
mixed —

addMiddleware()

Adds middleware to the queue.

public addMiddleware(callable|MiddlewareInterface $middleware) : void
Parameters
$middleware : callable|MiddlewareInterface

Middleware to add to the queue.

Tags
throws
InvalidArgumentException

If the provided middleware is not callable or does not implement MiddlewareInterface.

Return values
void —

handle()

Handles the request by processing the middleware queue.

public handle(ServerRequestInterface $request) : ResponseInterface
Parameters
$request : ServerRequestInterface

The incoming server request.

Tags
throws
Throwable

If an exception occurs during middleware processing.

Return values
ResponseInterface —

The response from the middleware or final handler.

getNextHandler()

Creates a new instance of MiddlewareDispatcher with the remaining middleware queue.

private getNextHandler() : static
Return values
static —

A new handler with the remaining middleware.

Search results