Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RateLimiter ¶
func RateLimiter(s Store, options *Options) gin.HandlerFunc
RateLimiter is a function to get gin.HandlerFunc
Types ¶
type InMemoryOptions ¶
type MemcachedOptions ¶
type MemcachedOptions struct { // the user can make Limit amount of requests every Rate Rate time.Duration // the amount of requests that can be made every Rate Limit uint MemcachedClient memcache.Client // should gin-rate-limit panic when there is an error with redis PanicOnErr bool // a function that returns true if the request should not count toward the rate limit Skip func(*gin.Context) bool }
type RedisOptions ¶
type RedisOptions struct { // the user can make Limit amount of requests every Rate Rate time.Duration // the amount of requests that can be made every Rate Limit uint RedisClient redis.UniversalClient // should gin-rate-limit panic when there is an error with redis PanicOnErr bool // a function that returns true if the request should not count toward the rate limit Skip func(*gin.Context) bool }
type Store ¶
type Store interface { // Limit takes in a key and *gin.Context and should return whether that key is allowed to make another request Limit(key string, c *gin.Context) Info }
func InMemoryStore ¶
func InMemoryStore(options *InMemoryOptions) Store
func MemcachedStore ¶
func MemcachedStore(options *MemcachedOptions) Store
func RedisStore ¶
func RedisStore(options *RedisOptions) Store
Click to show internal directories.
Click to hide internal directories.