Skip to content
docsv0.1.0

Router

Minimal {@see RouterInterface} implementation: exact segments plus single-segment `{placeholder}`s. Never throws, never returns null — {@see RouteResult} carries the outcome, exactly as the published contract demands. Ported (not reimplemented from scratch) from `example-agent-ready-blog`'s `App\Http\Router` — `milpa/http` ships the `RouterInterface` contract and the route/result value objects but no concrete matcher, and the example already proved this exact shape against the real published types. See the front's report for why this is a port and not a `milpa/http` dependency.

Router::__construct()

public function __construct(Milpa\Http\Routing\Route ...$routes):

Parameters

Parameters of __construct()
NameTypeDescription
$routesMilpa\Http\Routing\Route

Router::match()

public function match(Psr\Http\Message\ServerRequestInterface $request): Milpa\Http\Routing\RouteResult

Resolves the request to a typed result — always MATCHED, NOT_FOUND or METHOD_NOT_ALLOWED, never null.

Parameters

Parameters of match()
NameTypeDescription
$requestPsr\Http\Message\ServerRequestInterface