ThrottleRequests
class ThrottleRequests
Properties
protected RateLimiter | $limiter | The rate limiter instance. |
Methods
void
mixed
string
Response
buildResponse(string $key, int $maxAttempts)
Create a 'too many attempts' response.
Response
addHeaders(Response $response, int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null)
Add the limit header information to the given response.
int
calculateRemainingAttempts(string $key, int $maxAttempts, int|null $retryAfter = null)
Calculate the number of remaining attempts.
Details
at line 25
void
__construct(RateLimiter $limiter)
Create a new request throttler.
at line 39
mixed
handle(Request $request, Closure $next, int $maxAttempts = 60, float|int $decayMinutes = 1)
Handle an incoming request.
at line 63
protected string
resolveRequestSignature(Request $request)
Resolve request signature.
at line 75
protected Response
buildResponse(string $key, int $maxAttempts)
Create a 'too many attempts' response.
at line 97
protected Response
addHeaders(Response $response, int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null)
Add the limit header information to the given response.
at line 122
protected int
calculateRemainingAttempts(string $key, int $maxAttempts, int|null $retryAfter = null)
Calculate the number of remaining attempts.