Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultCacheTTL = time.Minute * 5
Variables ¶
View Source
var (
RateErr = errors.New("too many requests")
)
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct {
sync.Mutex
RateLimit rate.Limit
BucketSize int
// contains filtered or unexported fields
}
func (*Limiter) Limit ¶
func (gl *Limiter) Limit() gin.HandlerFunc
RateLimit gin middleware that limit the requests per second per context. Each request is identified by the ip address and cached in the limiter, until dropped by the lru cache or until expired.
Click to show internal directories.
Click to hide internal directories.