Documentation ¶
Overview ¶
Package tollbooth provides rate-limiting logic to HTTP request handler.
Index ¶
- func BuildKeys(limiter *config.Limiter, r *http.Request) [][]string
- func LimitByKeys(limiter *config.Limiter, keys []string) *errors.HTTPError
- func LimitByRequest(limiter *config.Limiter, r *http.Request) *errors.HTTPError
- func LimitFuncHandler(limiter *config.Limiter, nextFunc func(http.ResponseWriter, *http.Request)) http.Handler
- func LimitHandler(limiter *config.Limiter, next http.Handler) http.Handler
- func NewLimiter(max int64, ttl time.Duration) *config.Limiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildKeys ¶
BuildKeys generates a slice of keys to rate-limit by given config and request structs.
func LimitByKeys ¶
LimitByKeys keeps track number of request made by keys separated by pipe. It returns HTTPError when limit is exceeded.
func LimitByRequest ¶
LimitByRequest builds keys based on http.Request struct, loops through all the keys, and check if any one of them returns HTTPError.
func LimitFuncHandler ¶
func LimitFuncHandler(limiter *config.Limiter, nextFunc func(http.ResponseWriter, *http.Request)) http.Handler
LimitFuncHandler is a middleware that performs rate-limiting given request handler function.
func LimitHandler ¶
LimitHandler is a middleware that performs rate-limiting given http.Handler struct.
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Godeps
|
|
_workspace/src/github.com/juju/ratelimit
The ratelimit package provides an efficient token bucket implementation.
|
The ratelimit package provides an efficient token bucket implementation. |
Package config provides data structure to configure rate-limiter.
|
Package config provides data structure to configure rate-limiter. |
Package errors provide data structure for errors.
|
Package errors provide data structure for errors. |
Package libstring provides various string related functions.
|
Package libstring provides various string related functions. |
thirdparty
|
|
Click to show internal directories.
Click to hide internal directories.