有什么方法可以使用中间件并根据某些参数发送多个请求?
更具体地说,我需要:
class MyMiddleware
{
/**
* @param callable $handler
* @return \Closure
*/
public function __invoke(callable $handler)
{
return function (RequestInterface $request, array $options) use ($handler) {
if(!isset($options['token']){
//request the token from a url
}
//after the token is aquired proceed with the original request
return $handler($request, $options);
};
}
}