PHP 클래스 yii\filters\RateLimiter
You may use RateLimiter by attaching it as a behavior to a controller or module, like the following,
php
public function behaviors()
{
return [
'rateLimiter' => [
'class' => \yii\filters\RateLimiter::className(),
],
];
}
When the user has exceeded his rate limit, RateLimiter will throw a [[TooManyRequestsHttpException]] exception.
Note that RateLimiter requires [[user]] to implement the
RateLimitInterface. RateLimiter will
do nothing if [[user]] is not set or does not implement
RateLimitInterface.
파일 보기
프로젝트 열기: yiisoft/yii2
1 사용 예제들
공개 프로퍼티들
프로퍼티 |
타입 |
설명 |
|
$enableRateLimitHeaders |
|
whether to include rate limit headers in the response |
|
$errorMessage |
|
the message to be displayed when rate limit exceeds |
|
$request |
|
the current request. If not set, the request application component will be used. |
|
$response |
|
the response to be sent. If not set, the response application component will be used. |
|
$user |
|
the user object that implements the RateLimitInterface.
If not set, it will take the value of Yii::$app->user->getIdentity(false). |
|
공개 메소드들
메소드 상세
Checks whether the rate limit exceeds.
public checkRateLimit ( yii\filters\RateLimitInterface $user, Request $request, Response $response, Action $action ) |
$user |
yii\filters\RateLimitInterface |
the current user |
$request |
yii\web\Request |
|
$response |
yii\web\Response |
|
$action |
yii\base\Action |
the action to be executed |
프로퍼티 상세
the message to be displayed when rate limit exceeds
the current request. If not set, the request application component will be used.
the response to be sent. If not set, the response application component will be used.
the user object that implements the RateLimitInterface.
If not set, it will take the value of Yii::$app->user->getIdentity(false).