Documentation ¶
Index ¶
- Constants
- func GetRemoteIP(r *http.Request) (string, error)
- func IsWhitelistIPAddress(address string, localIPNets []*net.IPNet) bool
- func MatchMethod(methods, method string) bool
- func MatchStatus(status, s string) bool
- func ParseHTTPTime(value string) (time.Time, error)
- func SetRetryAfterHeader(header http.Header, retryAfter time.Duration)
- type CaddyLimiter
- func (cl *CaddyLimiter) Allow(keys []string, rule Rule, limiter ...*rate.Limiter) bool
- func (cl *CaddyLimiter) AllowN(keys []string, rule Rule, n int, limiter ...*rate.Limiter) bool
- func (cl *CaddyLimiter) GetLimiter(key string) *rate.Limiter
- func (cl *CaddyLimiter) GetLimiterOk(key string) (*rate.Limiter, bool)
- func (cl *CaddyLimiter) HasLimiter(key string) bool
- func (cl *CaddyLimiter) Reserve(keys []string) bool
- func (cl *CaddyLimiter) RetryAfter(keys []string, limiter ...*rate.Limiter) time.Duration
- func (cl *CaddyLimiter) SetLimiter(key string, limiter *rate.Limiter)
- type RateLimit
- type Rule
Constants ¶
View Source
const HTTPTimeLayout = "Mon, 02 Jan 2006 15:04:05 GMT"
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) GetLimiter ¶ added in v1.6.9
func (cl *CaddyLimiter) GetLimiter(key string) *rate.Limiter
func (*CaddyLimiter) GetLimiterOk ¶ added in v1.6.9
func (cl *CaddyLimiter) GetLimiterOk(key string) (*rate.Limiter, bool)
func (*CaddyLimiter) HasLimiter ¶ added in v1.6.9
func (cl *CaddyLimiter) HasLimiter(key string) bool
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 ¶
RetryAfter return a helper message for client
func (*CaddyLimiter) SetLimiter ¶ added in v1.6.9
func (cl *CaddyLimiter) SetLimiter(key string, limiter *rate.Limiter)
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.