Documentation
¶
Overview ¶
Package config provides data structure to configure rate-limiter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct {
// HTTP message when limit is reached.
Message string
// Content-Type for Message
MessageContentType string
// HTTP status code when limit is reached.
StatusCode int
// Maximum number of requests to limit per duration.
Max int64
// Duration of rate-limiter.
TTL time.Duration
// List of places to look up IP address.
// Default is "RemoteAddr", "X-Forwarded-For", "X-Real-IP".
// You can rearrange the order as you like.
IPLookups []string
// List of HTTP Methods to limit (GET, POST, PUT, etc.).
// Empty means limit all methods.
Methods []string
// List of HTTP headers to limit.
// Empty means skip headers checking.
Headers map[string][]string
// List of basic auth usernames to limit.
BasicAuthUsers []string
sync.RWMutex
// contains filtered or unexported fields
}
Limiter is a config struct to limit a particular request handler.
func NewLimiter ¶
NewLimiter is a constructor for Limiter.
func (*Limiter) LimitReached ¶
LimitReached returns a bool indicating if the Bucket identified by key ran out of tokens.
Click to show internal directories.
Click to hide internal directories.