Spec-Zone.ru › Laravel 10

ThrottleRequests

класс ThrottleRequests (Просмотреть исходный код)

Свойства

InteractsWithTime

Свойства

protected RateLimiter $limiter

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

static protected bool $shouldHashKeys

Указывает, должны ли ключи ограничения скорости быть хешированы.

Методы

int secondsUntil(DateTimeInterface|DateInterval|int $delay)

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

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

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

from InteractsWithTime
DateTimeInterface|int parseDateInterval(DateTimeInterface|DateInterval|int $delay)

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

from InteractsWithTime
int currentTime()

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

from InteractsWithTime
void __construct(RateLimiter $limiter)

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

static string using(string $name)

Указать используемый ограничитель запросов с именем для middleware.

static string with(int $maxAttempts = 60, int $decayMinutes = 1, string $prefix = '')

Указать конфигурацию ограничителя запросов для middleware.

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|HttpResponseException 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)

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

static void shouldHashKeys(bool $shouldHashKeys = true)

Указать, должны ли ключи ограничителей запросов быть хэшированы.

Details

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

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

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

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

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

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

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

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

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

DateTimeInterface|int

protected int currentTime()

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

Return Value

int

void __construct(RateLimiter $limiter)

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

Параметры

RateLimiter $limiter

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

void

static string using(string $name)

Указать используемый ограничитель запросов по имени для middleware.

Параметры

string $name

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

string

static string with(int $maxAttempts = 60, int $decayMinutes = 1, string $prefix = '')

Указать конфигурацию ограничителя запросов для middleware.

Параметры

int $maxAttempts
int $decayMinutes
string $prefix

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

string

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|HttpResponseException buildException(Request $request, string $key, int $maxAttempts, callable|null $responseCallback = null)

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

Параметры

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

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

ThrottleRequestsException|HttpResponseException

protected int getTimeUntilNextRetry(string $key)

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

Параметры

string $key

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

int

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

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

Параметры

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

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

Response

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

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

Параметры

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

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

array

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

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

Параметры

string $key
int $maxAttempts
int|null $retryAfter

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

int

static void shouldHashKeys(bool $shouldHashKeys = true)

Укажите, должны ли ключи лимитера скорости хэшироваться.

Параметры

bool $shouldHashKeys

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

void

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

Spec-Zone.ru

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