Class yii\filters\RateLimiter
Inheritance | yii\filters\RateLimiter » yii\base\ActionFilter » yii\base\Behavior » yii\base\Object | ||||
---|---|---|---|---|---|
Implements | yii\base\Configurable | ||||
Available since version | 2.0 | ||||
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/filters/RateLimiter.php |
You may use RateLimiter by attaching it as a behavior to a controller or module, like the following,
public function behaviors()
{
return [
'rateLimiter' => [
'class' => \yii\filters\RateLimiter::className(),
],
];
}
When the user has exceeded his rate limit, RateLimiter will throw a yii\web\TooManyRequestsHttpException exception.Note that RateLimiter requires $user to implement the yii\filters\RateLimitInterface. RateLimiter will do nothing if $user is not set or does not implement yii\filters\RateLimitInterface.
Không có nhận xét nào:
Đăng nhận xét