项目作者: hrodic

项目描述 :
Rate limit middleware for golang echo framework
高级语言: Go
项目地址: git://github.com/hrodic/golang-echo-simple-rate-limit-middleware.git
创建时间: 2019-08-17T13:49:26Z
项目社区:https://github.com/hrodic/golang-echo-simple-rate-limit-middleware

开源协议:MIT License

下载


golang-echo-simple-rate-limit-middleware

Rate limit middleware for golang echo framework

Requirements

Usage

As any other middleware:

  1. e := echo.New()
  2. e.Use(RateLimitWithConfig(RateLimitConfig{
  3. Limit: 2,
  4. Burst: 2,
  5. }))

run your server and try out the middleware easily with curl

  1. while true; do curl https://localhost:8080 --insecure; done

responses

  1. ...
  2. ...
  3. ...
  4. HTTP/2 200
  5. access-control-allow-origin:
  6. content-type: application/json; charset=UTF-8
  7. vary: Accept-Encoding
  8. vary: Origin
  9. x-content-type-options: nosniff
  10. x-frame-options: SAMEORIGIN
  11. x-request-id: eVdqddyz8XHFJ2UgDjlOb7QbfY23Hfyi
  12. x-xss-protection: 1; mode=block
  13. content-length: 32
  14. date: Sat, 17 Aug 2019 13:59:49 GMT
  15. {"application":"","version":""}
  16. HTTP/2 429
  17. content-type: application/json; charset=UTF-8
  18. content-length: 32
  19. date: Sat, 17 Aug 2019 13:59:49 GMT
  20. {"message":"Too Many Requests"}