ThrottleRequests
class ThrottleRequests (View source)
Особенности
| InteractsWithTime |
Свойства
| protected RateLimiter | $limiter | Экземпляр лимитера. |
Методы
| int | secondsUntil(DateTimeInterface|DateInterval|int $delay) Получить количество секунд до заданного DateTime. | from InteractsWithTime |
| int | availableAt(DateTimeInterface|DateInterval|int $delay = 0) Получить отметку времени "доступно в" в формате UNIX timestamp. | from InteractsWithTime |
| DateTimeInterface|int | parseDateInterval(DateTimeInterface|DateInterval|int $delay) Если заданное значение является интервалом, преобразовать его в экземпляр DateTime. | from InteractsWithTime |
| int | currentTime() Получить текущее системное время в формате UNIX timestamp. | from 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)
Получить количество секунд до заданного DateTime.
protected int availableAt(DateTimeInterface|DateInterval|int $delay = 0)
Получить отметку времени "доступно в" в формате UNIX timestamp.
protected DateTimeInterface|int parseDateInterval(DateTimeInterface|DateInterval|int $delay)
Если заданное значение является интервалом, преобразовать его в экземпляр DateTime.
protected int currentTime()
Получить текущее системное время в формате UNIX timestamp.
void __construct(RateLimiter $limiter)
Создать новый ограничиватель запросов.
Ответ handle(Запрос $request, Closure $next, int|string $maxAttempts = 60, float|int $decayMinutes = 1, string $prefix = '')
Обработка входящего запроса.
protected Ответ handleRequestUsingNamedLimiter(Запрос $request, Closure $next, string $limiterName, Closure $limiter)
Обработка входящего запроса.
protected Ответ handleRequest(Запрос $request, Closure $next, array $limits)
Обработка входящего запроса.
protected int resolveMaxAttempts(Запрос $request, int|string $maxAttempts)
Определение количества попыток, если пользователь аутентифицирован или нет.
protected string resolveRequestSignature(Запрос $request)
Определение подписи запроса.
protected ThrottleRequestsException buildException(Запрос $request, string $key, int $maxAttempts, callable|null $responseCallback = null)
Создание исключения «слишком много попыток».
protected int getTimeUntilNextRetry(string $key)
Получение количества секунд до следующей попытки.
protected Ответ addHeaders(Ответ $response, int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null)
Добавление информации о лимите в заданный ответ.
protected array getHeaders(int $maxAttempts, int $remainingAttempts, int|null $retryAfter = null, Ответ|null $response = null)
Получение информации о заголовках лимита.
protected int calculateRemainingAttempts(string $key, int $maxAttempts, int|null $retryAfter = null)
Вычисление оставшегося количества попыток.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/9.x/Illuminate/Routing/Middleware/ThrottleRequests.html