github.com/goravel/framework@v1.13.9/contracts/http/rate_limiter.go (about) 1 package http 2 3 //go:generate mockery --name=RateLimiter 4 type RateLimiter interface { 5 // For register a new rate limiter. 6 For(name string, callback func(ctx Context) Limit) 7 // ForWithLimits register a new rate limiter with limits. 8 ForWithLimits(name string, callback func(ctx Context) []Limit) 9 // Limiter get a rate limiter instance by name. 10 Limiter(name string) func(ctx Context) []Limit 11 } 12 13 type Limit interface { 14 // By set the signature key name for the rate limiter. 15 By(key string) Limit 16 // Response set the response callback that should be used. 17 Response(func(ctx Context)) Limit 18 }