全栈小学生 0e47055ccb v1.0.0-beta.1
2023-04-15 17:12:49 +08:00

24 lines
628 B
PHP

<?php
namespace Qcloud\Cos;
use Psr\Http\Message\RequestInterface;
class SignatureMiddleware {
private $nextHandler;
protected $signature;
/**
* @param callable $nextHandler Next handler to invoke.
*/
public function __construct(callable $nextHandler, $accessKey, $secretKey, $options) {
$this->nextHandler = $nextHandler;
$this->signature = new Signature($accessKey, $secretKey, $options);
}
public function __invoke(RequestInterface $request, array $options) {
$fn = $this->nextHandler;
return $fn($this->signature->signRequest($request), $options);
}
}