Documentation
¶
Overview ¶
Package tollbooth provides rate-limiting logic to HTTP request handler.
Index ¶
- func BuildKeys(lmt *limiter.Limiter, r *http.Request) [][]string
- func LimitByKeys(lmt *limiter.Limiter, keys []string) *errors.HTTPError
- func LimitByRequest(lmt *limiter.Limiter, w http.ResponseWriter, r *http.Request) *errors.HTTPError
- func LimitFuncHandler(lmt *limiter.Limiter, nextFunc func(http.ResponseWriter, *http.Request)) http.Handler
- func LimitHandler(lmt *limiter.Limiter, next http.Handler) http.Handler
- func NewLimiter(max int64, tbOptions *limiter.ExpirableOptions) *limiter.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 limiter 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(lmt *limiter.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.
func NewLimiter ¶
func NewLimiter(max int64, tbOptions *limiter.ExpirableOptions) *limiter.Limiter
NewLimiter is a convenience function to limiter.New.
Types ¶
This section is empty.
Directories
¶
Path | Synopsis |
---|---|
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. |
Package limiter provides data structure to configure rate-limiter.
|
Package limiter provides data structure to configure rate-limiter. |