Skip to content
docsv0.1.0

RequestHandler

The web entry point over a booted {@see Kernel}: matches the request against the kernel's `milpa/http` route table and dispatches to the resolved controller, or answers 404/405 — never a legacy `Milpa\Web` request/response pair, only `psr/http-message` types, per this front's mandate to route+dispatch entirely on `milpa/http`. Building the 404/405 responses needs a concrete PSR-7 message implementation, so this class takes a PSR-17 {@see ResponseFactoryInterface} instead of hardcoding one (nyholm, guzzle, …) — the host wires whichever implementation it already depends on.

RequestHandler::__construct()

public function __construct(Milpa\Runtime\Kernel $kernel, Psr\Http\Message\ResponseFactoryInterface $responseFactory):

Parameters

Parameters of __construct()
NameTypeDescription
$kernelMilpa\Runtime\Kernel
$responseFactoryPsr\Http\Message\ResponseFactoryInterface

RequestHandler::handle()

public function handle(Psr\Http\Message\ServerRequestInterface $request): Psr\Http\Message\ResponseInterface

Matches `$request` against the kernel's route table and returns the controller's response, or a 404/405 built from the injected response factory.

Parameters

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