From 0ce503415e17571f735695f6f33a70b0402415ca Mon Sep 17 00:00:00 2001 From: hongweipeng Date: Fri, 2 May 2025 09:45:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B3=A8=E8=A7=A3=E7=9A=84=E7=BC=93?= =?UTF-8?q?=E5=AD=98key=E8=A1=A5=E5=85=85=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Throttle.php | 2 ++ tests/Base.php | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) 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; }