ethercreative/yii2-ip-ratelimiter
最新稳定版本:1.0
Composer 安装命令:
composer require ethercreative/yii2-ip-ratelimiter
包简介
Allow guest clients to be rate limited, using their IP as the identifier.
关键字:
README 文档
README
yii2-ip-ratelimiter
Allow guest clients to be rate limited, using their IP as the identifier.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require ethercreative/yii2-ip-ratelimiter "1.*"
or add
"ethercreative/yii2-ip-ratelimiter": "1.*"
to the require section of your composer.json file.
Usage
Modify the bahavior method of the controller you want to rate limit
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['rateLimiter'] = [
// Use class
'class' => \ethercreative\ratelimiter\RateLimiter::className(),
// The maximum number of allowed requests
'rateLimit' => 100,
// The time period for the rates to apply to
'timePeriod' => 600,
// Separate rate limiting for guests and authenticated users
// Defaults to true
// - false: use one set of rates, whether you are authenticated or not
// - true: use separate ratesfor guests and authenticated users
'separateRates' => false,
// Whether to return HTTP headers containing the current rate limiting information
'enableRateLimitHeaders' => false,
];
return $behaviors;
}
统计信息
- 总下载量: 132.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 36
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-29
