diff --git a/src/Throttle.php b/src/Throttle.php index 658cb0e..e5d9cc8 100644 --- a/src/Throttle.php +++ b/src/Throttle.php @@ -220,6 +220,8 @@ protected function allowRequestByAnnotation(Request $request): bool foreach ($attributes as $attribute) { $annotation = $attribute->newInstance(); $key = $this->getCacheKey($request, $annotation->key, $annotation->driver); + $key = $controller . $action . $key; // 注解需要以实际方法作为前缀 + if (!$this->allowRequest($key, $annotation->rate, $annotation->driver)) { $this->config['visit_fail_text'] = $annotation->message; return false; diff --git a/tests/Base.php b/tests/Base.php index b7b74b8..770c674 100644 --- a/tests/Base.php +++ b/tests/Base.php @@ -61,7 +61,6 @@ function create_request(string $uri, string $method = 'GET', string $host = '127 function visit_with_http_code(Request $request, int $http_code = 200): bool { $response = $this->get_response($request); - return $response->getCode() == $http_code; }