Skip to content
docsv0.9.1

ContainerMiddlewareResolver

The concrete `milpa/http` {@see MiddlewareResolverInterface} its docblock has promised since day one: the "concrete resolver (pulling instances from the DI container) lives in the host kernel". Pulls the PSR-15 middleware named by a route's `middleware[]` `class-string` out of a PSR-11 container — the same container {@see ContainerHandlerResolver} draws controllers from. It fails CLOSED, never silent: a reference the container cannot produce, or one that resolves to something that is not a {@see MiddlewareInterface}, throws instead of returning null or being skipped — because a declared-but-unresolved middleware would leave the route it guards silently unprotected, the one outcome a security-bearing pipeline must never reach.

ContainerMiddlewareResolver::__construct()

public function __construct(Psr\Container\ContainerInterface $container):

Parameters

Parameters of __construct()
NameTypeDescription
$containerPsr\Container\ContainerInterface

ContainerMiddlewareResolver::resolve()

public function resolve(string $middleware): Psr\Http\Server\MiddlewareInterface

Resolves a per-route middleware reference into a live PSR-15 middleware, or throws a clear fail-closed error when it cannot.

Parameters

Parameters of resolve()
NameTypeDescription
$middlewarestring