ThrottleRequests

class ThrottleRequests (View source)

Properties

protected RateLimiter $limiter The rate limiter instance.

Methods

void __construct(RateLimiter $limiter)

Create a new request throttler.

mixed handle(Request $request, Closure $next, int $maxAttempts = 60, float|int $decayMinutes = 1)

Handle an incoming request.

string resolveRequestSignature(Request $request)

Resolve request signature.

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

void __construct(RateLimiter $limiter)

Create a new request throttler.

Parameters

RateLimiter $limiter

Return Value

void

mixed handle(Request $request, Closure $next, int $maxAttempts = 60, float|int $decayMinutes = 1)

Handle an incoming request.

Parameters

Request $request
Closure $next
int $maxAttempts
float|int $decayMinutes

Return Value

mixed

protected string resolveRequestSignature(Request $request)

Resolve request signature.

Parameters

Request $request

Return Value

string

protected Response buildResponse(string $key, int $maxAttempts)

Create a 'too many attempts' response.

Parameters

string $key
int $maxAttempts

Return Value

Response

protected Response addHeaders(Response $response, int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null)

Add the limit header information to the given response.

Parameters

Response $response
int $maxAttempts
int $remainingAttempts
int|null $retryAfter

Return Value

Response

protected int calculateRemainingAttempts(string $key, int $maxAttempts, int|null $retryAfter = null)

Calculate the number of remaining attempts.

Parameters

string $key
int $maxAttempts
int|null $retryAfter

Return Value

int

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.3/Illuminate/Routing/Middleware/ThrottleRequests.html