Skip to content
docsv0.1.0

CallableRequestHandler

Adapts a controller instance plus a method name — the two halves of `milpa/http`'s `HandlerReference` — into a live PSR-15 {@see RequestHandlerInterface}. The controller method is called with the (route-result-decorated) request and MUST return a {@see ResponseInterface}; anything else is a controller-authoring bug, surfaced loudly rather than coerced.

CallableRequestHandler::__construct()

public function __construct(object $controller, string $method):

Parameters

Parameters of __construct()
NameTypeDescription
$controllerobject
$methodstring

CallableRequestHandler::handle()

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

Invokes the wrapped controller method and returns its response.

Parameters

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