Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRemoteIP ¶
GetRemoteIP returns the ip of requester Doesn't care if the ip is real or not
func IsWhitelistIPAddress ¶ added in v1.3.0
IsWhitelistIPAddress check whether an ip is in whitelist
func MatchMethod ¶ added in v1.3.0
MatchMethod check whether the request method is in the methods list
func MatchStatus ¶ added in v1.5.0
MatchStatus check whether the upstream response status code is in the status list
Types ¶
type CaddyLimiter ¶
func NewCaddyLimiter ¶
func NewCaddyLimiter() *CaddyLimiter
func (*CaddyLimiter) Allow ¶
func (cl *CaddyLimiter) Allow(keys []string, rule Rule) bool
Allow is just a shortcut for AllowN
func (*CaddyLimiter) AllowN ¶
func (cl *CaddyLimiter) AllowN(keys []string, rule Rule, n int) bool
AllowN check if n count are allowed for a specific key
func (*CaddyLimiter) CheckKeyExists ¶ added in v1.6.6
func (cl *CaddyLimiter) CheckKeyExists(k string) bool
CheckKeyExists is used to check if a key exists in map
func (*CaddyLimiter) Reserve ¶ added in v1.5.0
func (cl *CaddyLimiter) Reserve(keys []string) bool
Reserve will consume 1 token from `token bucket`
func (*CaddyLimiter) RetryAfter ¶
func (cl *CaddyLimiter) RetryAfter(keys []string) time.Duration
RetryAfter return a helper message for client
type RateLimit ¶
type RateLimit struct { Next httpserver.Handler Rules []Rule }
RateLimit is an http.Handler that can limit request rate to specific paths or files
Click to show internal directories.
Click to hide internal directories.