mini\Dispatcher\HttpDispatcher::addMiddleware()
Method
public
Signature
public function addMiddleware(Psr\Http\Server\MiddlewareInterface $middleware): self
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$middleware |
Psr\Http\Server\MiddlewareInterface |
required | Documentation missing |
Returns
self
Documentation
Add middleware to the request pipeline
Middleware is executed in the order added (FIFO). Can only be called during Bootstrap phase - throws exception if called after Ready phase.
Examples:
// In bootstrap.php or module functions.php
$dispatcher = Mini::$mini->get(HttpDispatcher::class);
$dispatcher->addMiddleware(Mini::$mini->get(StaticFiles::class));
$dispatcher->addMiddleware(new CorsMiddleware());
$dispatcher->addMiddleware(new AuthMiddleware());