Spec-Zone.ru › Laravel 8

ThrottleRequests

class ThrottleRequests (View source)

Свойства

InteractsWithTime

Свойства

protected RateLimiter $limiter

Экземпляр ограничителя скорости.

Методы

int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Получить количество секунд до указанной даты DateTime.

из InteractsWithTime
int availableAt(DateTimeInterface|DateInterval|int $delay = 0)

Получить отметку времени «доступно в» в формате UNIX.

из InteractsWithTime
DateTimeInterface|int parseDateInterval(DateTimeInterface|DateInterval|int $delay)

Если заданное значение — интервал, преобразовать его в экземпляр DateTime.

из InteractsWithTime
int currentTime()

Получить текущее системное время в формате UNIX timestamp.

из InteractsWithTime
void __construct(RateLimiter $limiter)

Создать новый ограничитель запросов.

Response handle(Request $request, Closure $next, int|string $maxAttempts = 60, float|int $decayMinutes = 1, string $prefix = '')

Обработать входящий запрос.

Response handleRequestUsingNamedLimiter(Request $request, Closure $next, string $limiterName, Closure $limiter)

Обработать входящий запрос.

Response handleRequest(Request $request, Closure $next, array $limits)

Обработать входящий запрос.

int resolveMaxAttempts(Request $request, int|string $maxAttempts)

Определить количество попыток, если пользователь авторизован или нет.

string resolveRequestSignature(Request $request)

Определить подпись запроса.

ThrottleRequestsException buildException(Request $request, string $key, int $maxAttempts, callable|null $responseCallback = null)

Создать исключение «слишком много попыток».

int getTimeUntilNextRetry(string $key)

Получить количество секунд до следующей попытки.

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

Добавить информацию о лимитах в заголовки ответа.

array getHeaders(int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null, Response|null $response = null)

Получить информацию о заголовках ограничений.

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

Вычислить количество оставшихся попыток.

Подробности

protected int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Получить количество секунд до заданной даты и времени.

Параметры

DateTimeInterface|DateInterval|int $delay

Возвращаемое значение

int

protected int availableAt(DateTimeInterface|DateInterval|int $delay = 0)

Получить отметку времени UNIX "доступно в" (available at).

Параметры

DateTimeInterface|DateInterval|int $delay

Возвращаемое значение

int

protected DateTimeInterface|int parseDateInterval(DateTimeInterface|DateInterval|int $delay)

Если заданное значение является интервалом, преобразует его в экземпляр DateTime.

Параметры

DateTimeInterface|DateInterval|int $delay

Возвращаемое значение

DateTimeInterface|int

protected int currentTime()

Получить текущее системное время в виде отметки времени UNIX.

Возвращаемое значение

int

void __construct(RateLimiter $limiter)

Создать новый ограничитель запросов.

Параметры

RateLimiter $limiter

Возвращаемое значение

void

Response handle(Request $request, Closure $next, int|string $maxAttempts = 60, float|int $decayMinutes = 1, string $prefix = '')

Обработать входящий запрос.

Параметры

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

Возвращаемое значение

Response

Исключения

ThrottleRequestsException

protected Response handleRequestUsingNamedLimiter(Request $request, Closure $next, string $limiterName, Closure $limiter)

Обработать входящий запрос.

Параметры

Request $request
Closure $next
string $limiterName
Closure $limiter

Возвращаемое значение

Response

Исключения

ThrottleRequestsException

protected Response handleRequest(Request $request, Closure $next, array $limits)

Обработать входящий запрос.

Параметры

Request $request
Closure $next
array $limits

Возвращаемое значение

Response

Исключения

ThrottleRequestsException

protected int resolveMaxAttempts(Request $request, int|string $maxAttempts)

Определить количество попыток, если пользователь аутентифицирован или нет.

Параметры

Request $request
int|string $maxAttempts

Возвращаемое значение

int

protected string resolveRequestSignature(Request $request)

Определить подпись запроса.

Параметры

Request $request

Возвращаемое значение

string

Исключения

RuntimeException

protected ThrottleRequestsException buildException(Request $request, string $key, int $maxAttempts, callable|null $responseCallback = null)

Создать исключение 'слишком много попыток'.

Параметры

Request $request
string $key
int $maxAttempts
callable|null $responseCallback

Возвращаемое значение

ThrottleRequestsException

protected int getTimeUntilNextRetry(string $key)

Получить количество секунд до следующей попытки.

Параметры

string $key

Возвращаемое значение

int

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

Добавить информацию о лимите в заданный ответ.

Parameters

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

Return Value

Response

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

Получить информацию о лимите.

Parameters

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

Return Value

array

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

Вычислить количество оставшихся попыток.

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/8.x/Illuminate/Routing/Middleware/ThrottleRequests.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API