7 releases

0.3.1 Jan 29, 2021
0.3.0 Jan 29, 2021
0.2.0 Jan 26, 2021
0.1.3 Jan 25, 2021

#98 in #rate-limiting

40 downloads per month
Used in kepton

MIT/Apache

13KB
300 lines

Rate-Limit middleware for actix-web

参考 GitHub API v3 接口,针对用户认证与否,有区别的限流。 比如认证用户,每小时可访问 600 次;未认证用户,根据 ip 划分,每小时可访问 60 次。

Reference

  1. Everything You Need To Know About API Rate Limiting
  2. GitHub API v3: Rate limiting
  3. Redis Pattern: Rate limiter

License

Apache or MIT


lib.rs:

Rate-Limit middleware for actix-web

Response headers:

  • X-RateLimit-Limit: 60
  • X-RateLimit-Remaining: 59
  • X-RateLimit-Reset: 1350085394

Dependencies

~27MB
~563K SLoC