Hello FIG & company,
I wanted to send a quick progress report on PSR-15. Life has been busy and the working group is doing its best to finish this up.
The first order of business is addressing the concerns brought up by Rasmus and Michael in this thread:
PSR-15 will define HandlerInterface, MiddlewareInterface, and DelegateInterface. These will be two separate packages (names subject to change):
psr/http-server-handler (handler)
psr/http-server-middleware (middleware + delegate, depends on handler)
The HandlerInterface signature will be:
__invoke(ServerRequestInterface $request): ResponseInterface
The MiddlewareInterface signature will be:
process(ServerRequestInterface $request, DelegateInterface $delegate): ResponseInterface
The DelegateInterface will simply be an extension of HandlerInterface. (Are we certain we need delegate?)
As such, a middleware would look something like this:
function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
if ($this->isNotValid($request)) {
// create ResponseInterface error
return $response;
}
// all good, continue processing
return $delegate($request);
}
As always, feedback and thoughts on this proposal are appreciated.