Open dbu opened 5 years ago
We cannot use PSR15 as it only accept a ServerRequestInterface (and it's way better, as client middleware does not have the same purpose as server middleware)
Also actually our plugin system rely on Promise as it's easy to switch from async to sync, but impossible to do otherwise (at least for php < 7.3)
However, i really believe in https://github.com/concurrent-php/ext-async which will allow us to use a PSR15 like interface for our plugin system (sync version) but still allow for async operation.
Also the $first
variable in our plugin can be dropped (we just need to inject an http client into plugin using this variable)
So our interface can become something like :
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
interface Plugin {
handleRequest(RequestInterface $request, ClientInterface $next): ResponseInterface;
}
is there exist proposal for creating http client middleware for future PSR?
reading https://medium.com/@timoschinkel/implementing-psr-18-and-extending-it-with-middleware-b33eeceb2753 it occured to me that our PluginClient essentially mimiks PSR-15. should we migrate our plugins to middleware, or is there value in having them as they are?