productloginratelimitMiddleware.go 707 B

12345678910111213141516171819202122232425
  1. // Code scaffolded by goctl. Safe to edit.
  2. // goctl 1.10.1
  3. package middleware
  4. import (
  5. "net/http"
  6. "github.com/zeromicro/go-zero/core/stores/redis"
  7. )
  8. type ProductLoginRateLimitMiddleware struct {
  9. rl *RateLimitMiddleware
  10. }
  11. // NewProductLoginRateLimitMiddleware 产品端登录限流:每 IP 每分钟最多 30 次。
  12. func NewProductLoginRateLimitMiddleware(rds *redis.Redis, keyPrefix string, behindProxy bool) *ProductLoginRateLimitMiddleware {
  13. return &ProductLoginRateLimitMiddleware{
  14. rl: NewRateLimitMiddleware(rds, 60, 30, keyPrefix+":rl:login:product", behindProxy),
  15. }
  16. }
  17. func (m *ProductLoginRateLimitMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
  18. return m.rl.Handle(next)
  19. }