Documentation ¶
Index ¶
- Variables
- func GetIP(r *http.Request) string
- func Limit(next http.Handler) http.Handler
- func NewAPILimiter(cfg *APILimiterConfig) error
- func NewBandwidthLimiter(r rate.Limit, b int)
- type APILimiterConfig
- type BandwidthLimiter
- type BandwidthLimiterConfig
- type IPLimitConfig
- type MemoryLimiterConfig
- type RateLimiterCell
- type RateLimiterConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var LimiterOnce sync.Once
Functions ¶
func GetIP ¶
GetIP gets a requests IP address by reading off the forwarded-for header (for proxies) and falls back to use the remote address.
func NewAPILimiter ¶
func NewAPILimiter(cfg *APILimiterConfig) error
func NewBandwidthLimiter ¶ added in v0.2.0
Types ¶
type APILimiterConfig ¶
type APILimiterConfig struct { IPLimitCfg IPLimitConfig PathPattern map[string]MemoryLimiterConfig APILimits map[string]MemoryLimiterConfig // routePrefix-apiName => limit config HostPattern map[string]MemoryLimiterConfig }
type BandwidthLimiter ¶ added in v0.2.0
var BandwidthLimit *BandwidthLimiter
type BandwidthLimiterConfig ¶ added in v0.2.0
type IPLimitConfig ¶ added in v0.2.2
type MemoryLimiterConfig ¶
type RateLimiterCell ¶
type RateLimiterConfig ¶
type RateLimiterConfig struct { IPLimitCfg IPLimitConfig PathPattern []RateLimiterCell HostPattern []RateLimiterCell APILimits []RateLimiterCell }
Click to show internal directories.
Click to hide internal directories.