egg-ratelimit
灵感来自于egg-ratemiter,优化支持 url search
Rate limiter for Egg.js backed by Redis.
- 支持配置路由限制访问速率
支持url search
- 支持Controller控制器内配置访问速率限制
依赖说明
依赖的 egg 版本
egg-ratelimit 版本 | egg 1.x |
---|---|
1.x | 😁 |
0.x | ❌ |
依赖的插件
开启插件
// config/plugin.jsexportsratelimit = enable: true package: 'egg-ratelimit';
使用说明
1. 路由配置
exportsratelimit = // 1. 开启配置 app: true // 2. 配置路由 router: path: '/index.html' // 路径 max: 3 // 单位时间最多访问次数 time: '1s' // 时间单位 s m h d y ... message: '请求太频繁,请稍候再试' // 自定义错误信息
2. Controller单独配置
// ... if await ctx return // 正常请求return // ... // ...
详细配置
请到 config/config.default.js 查看详细配置项说明。
提问交流
请到 egg issues 异步交流。