Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶ added in v2.11.0
type ConnectionPool ¶ added in v2.11.0
type ConnectionPool interface {
Connect() Connection
}
func GetRedisPool ¶ added in v2.11.0
func GetRedisPool(address string) ConnectionPool
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
func (*Limiter) Configure ¶
The LimitGenerator function should return the rate limit with corresponding key that should be used for the given path template path.pathTemplate should be the pathtemplate used to route the request
If you give multiple configs for 1 endpoint. The most restrictive one will apply
func (*Limiter) Middleware ¶
func (l *Limiter) Middleware() mux.MiddlewareFunc
Rate limiting middleware, you can configure 1 or many limits for each path template using a limitGenerator The algorithm is inspired from: https://redislabs.com/redis-best-practices/basic-rate-limiting/
The key will be stored in clear text in the cache. If the key contains personal data please consider hashing the key
func (*Limiter) SetConnectionPool ¶ added in v2.11.0
func (l *Limiter) SetConnectionPool(p ConnectionPool) *Limiter
Click to show internal directories.
Click to hide internal directories.