Skip to content

Commit 2eec968

Browse files
crynobonethilanga
authored andcommitted
Allow to use HasRateLimiter::getRateLimiter contracts (dingo#1366)
* Allow to use HasRateLimiter::getRateLimiter contracts This would allow developer to use custom `getRateLimiter()` when matching multiple throttle instead of just preset throttle instance. * Fixes CS
1 parent 492a6fe commit 2eec968

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Http/RateLimit/Handler.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ public function rateLimitRequest(Request $request, $limit = 0, $expires = 0)
9393
// If the throttle instance is already set then we'll just carry on as
9494
// per usual.
9595
if ($this->throttle instanceof Throttle) {
96-
if ($this->throttle instanceof HasRateLimiter) {
97-
$this->setRateLimiter([$this->throttle, 'getRateLimiter']);
98-
}
9996

10097
// If the developer specified a certain amount of requests or expiration
10198
// time on a specific route then we'll always use the route specific
@@ -118,6 +115,10 @@ public function rateLimitRequest(Request $request, $limit = 0, $expires = 0)
118115
return;
119116
}
120117

118+
if ($this->throttle instanceof HasRateLimiter) {
119+
$this->setRateLimiter([$this->throttle, 'getRateLimiter']);
120+
}
121+
121122
$this->prepareCacheStore();
122123

123124
$this->cache('requests', 0, $this->throttle->getExpires());

0 commit comments

Comments
 (0)