Documentation ¶
Index ¶
- Constants
- type BaseLimiter
- type CountryLimiter
- type GetParameterLimiter
- type HostLimiter
- type IPLimiter
- type Option
- func IgnorePathContains(ignorePathContains []string) Option
- func IgnorePathPrefixes(ignorePathPrefixes []string) Option
- func IgnorePathSuffixes(ignorePathSuffixes []string) Option
- func TargetConditionFunc(f func(r *http.Request) bool) Option
- func TargetExtensions(targetExtensions []string) Option
- func TargetMethods(targetMethods []string) Option
- type Options
- type RequestPathLimiter
- type UserAgentLimiter
Constants ¶
View Source
const ( RemoteAddrKey = "remote_addr" HostKey = "host" )
View Source
const ContextCountryKey key = iota
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseLimiter ¶
func NewBaseLimiter ¶
func NewBaseLimiter( reqLimit int, windowLen time.Duration, onRequestLimit func(*rl.Context, string) http.HandlerFunc, setters ...Option, ) BaseLimiter
func (*BaseLimiter) IsTargetRequest ¶
func (l *BaseLimiter) IsTargetRequest(r *http.Request) bool
func (*BaseLimiter) Name ¶
func (l *BaseLimiter) Name() string
func (*BaseLimiter) ShouldSetXRateLimitHeaders ¶
func (l *BaseLimiter) ShouldSetXRateLimitHeaders(r *rl.Context) bool
type CountryLimiter ¶
type CountryLimiter struct { BaseLimiter // contains filtered or unexported fields }
func NewCountryLimiter ¶
func NewCountryLimiter( dbPath string, countries []string, skipCountries []string, reqLimit int, windowLen time.Duration, onRequestLimit func(*rl.Context, string) http.HandlerFunc, setter ...Option, ) (*CountryLimiter, error)
国別のリクエスト数を制限する 制限単位はIPアドレス
func (*CountryLimiter) Name ¶
func (l *CountryLimiter) Name() string
func (*CountryLimiter) OnRequestLimit ¶
func (l *CountryLimiter) OnRequestLimit(r *rl.Context) http.HandlerFunc
type GetParameterLimiter ¶
type GetParameterLimiter struct { BaseLimiter // contains filtered or unexported fields }
func NewGetParameterLimiter ¶
func NewGetParameterLimiter( getParameters map[string]string, reqLimit int, windowLen time.Duration, key string, onRequestLimit func(*rl.Context, string) http.HandlerFunc, setter ...Option, ) (*GetParameterLimiter, error)
Getパラメーターごとにリクエスト数を制限する 制限単位はホスト名とGetパラメーター
func (*GetParameterLimiter) Name ¶
func (l *GetParameterLimiter) Name() string
func (*GetParameterLimiter) OnRequestLimit ¶
func (l *GetParameterLimiter) OnRequestLimit(r *rl.Context) http.HandlerFunc
type HostLimiter ¶
type HostLimiter struct {
BaseLimiter
}
func NewHostLimiter ¶
func NewHostLimiter( reqLimit int, windowLen time.Duration, onRequestLimit func(*rl.Context, string) http.HandlerFunc, setter ...Option, ) *HostLimiter
ホストごとにリクエスト数を制限する 制限単位はホスト名
func (*HostLimiter) Name ¶
func (l *HostLimiter) Name() string
func (*HostLimiter) OnRequestLimit ¶
func (l *HostLimiter) OnRequestLimit(r *rl.Context) http.HandlerFunc
type IPLimiter ¶
type IPLimiter struct {
BaseLimiter
}
func NewIPLimiter ¶
func NewIPLimiter( reqLimit int, windowLen time.Duration, onRequestLimit func(*rl.Context, string) http.HandlerFunc, setter ...Option, ) *IPLimiter
ホストごとにリクエスト数を制限する 制限単位はIP
func (*IPLimiter) OnRequestLimit ¶
func (l *IPLimiter) OnRequestLimit(r *rl.Context) http.HandlerFunc
type Option ¶ added in v0.0.8
type Option func(*Options)
func IgnorePathContains ¶ added in v0.0.8
func IgnorePathPrefixes ¶ added in v0.0.8
func IgnorePathSuffixes ¶ added in v0.0.8
func TargetConditionFunc ¶ added in v0.0.9
func TargetExtensions ¶ added in v0.0.8
func TargetMethods ¶ added in v0.0.8
type RequestPathLimiter ¶
type RequestPathLimiter struct { BaseLimiter // contains filtered or unexported fields }
func NewRequestPathLimiter ¶
func NewRequestPathLimiter( requestPathContains []string, requestPathPrefixes []string, requestPathSuffixes []string, reqLimit int, windowLen time.Duration, key string, onRequestLimit func(*rl.Context, string) http.HandlerFunc, setter ...Option, ) (*RequestPathLimiter, error)
リクエストパスごとにリクエスト数を制限する 制限単位はホスト名 + リクエストパス
func (*RequestPathLimiter) Name ¶
func (l *RequestPathLimiter) Name() string
func (*RequestPathLimiter) OnRequestLimit ¶
func (l *RequestPathLimiter) OnRequestLimit(r *rl.Context) http.HandlerFunc
type UserAgentLimiter ¶
type UserAgentLimiter struct { BaseLimiter // contains filtered or unexported fields }
func NewUserAgentLimiter ¶
func NewUserAgentLimiter( userAgents []string, reqLimit int, windowLen time.Duration, onRequestLimit func(*rl.Context, string) http.HandlerFunc, setter ...Option, ) *UserAgentLimiter
ユーザーエージェントごとにリクエスト数を制限する 制限単位はユーザーエージェント
func (*UserAgentLimiter) Name ¶
func (l *UserAgentLimiter) Name() string
func (*UserAgentLimiter) OnRequestLimit ¶
func (l *UserAgentLimiter) OnRequestLimit(r *rl.Context) http.HandlerFunc
Click to show internal directories.
Click to hide internal directories.