Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRedisLimitCounter ¶
func NewRedisLimitCounter(cfg *Config) (httprate.LimitCounter, error)
NewRedisLimitCounter returns a new redis-based LimitCounter.
func WithRedisLimitCounter ¶
WithRedisLimitCounter is middleware that can be fed to httprate. Example:
limiter := httprate.Limit(
serverOptions.RequestLimit,
serverOptions.RequestPeriod,
httprate.WithKeyByRealIP(),
httprateredis.WithRedisLimitCounter(
&httprateredis.Config{
Addresses: redisAddresses,
Password: redisPassword,
},
),
)
Types ¶
type Config ¶
type Config struct {
// Addresses is a list of redis host/ports, delimited like so:
// * []string{"127.0.0.1:6379"}
Addresses []string `toml:"host"`
// Password is the Redis password (if the cluster has one)
Password string `toml:"password"`
// DBIndex is the DB index to select
DBIndex int `toml:"db_index"` // default 0
}
Config defines the config of httprate-redis
Click to show internal directories.
Click to hide internal directories.