Documentation ¶
Index ¶
- func NewLimiter(opts ...limiterOption) web.FilterFunc
- func RemoteIPSessionKey(ctx *context.Context) string
- func WithBucketFactory(f func(opts ...bucketOption) bucket) limiterOption
- func WithCapacity(c uint) limiterOption
- func WithRate(r time.Duration) limiterOption
- func WithRejectionResponse(resp RejectionResponse) limiterOption
- func WithSessionKey(f func(ctx *context.Context) string) limiterOption
- type RejectionResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLimiter ¶
func NewLimiter(opts ...limiterOption) web.FilterFunc
NewLimiter return FilterFunc, the limiter enables rate limit according to the configuration.
func RemoteIPSessionKey ¶
func WithBucketFactory ¶
func WithBucketFactory(f func(opts ...bucketOption) bucket) limiterOption
WithBucketFactory return limiterOption. WithBucketFactory customize the implementation of Bucket.
func WithCapacity ¶
func WithCapacity(c uint) limiterOption
WithCapacity return limiterOption. WithCapacity config the capacity size. The bucket with a capacity of n has n tokens after initialization. The capacity defines how many requests a client can make in excess of the rate.
func WithRate ¶
WithRate return limiterOption. WithRate config how long it takes to generate a token.
func WithRejectionResponse ¶
func WithRejectionResponse(resp RejectionResponse) limiterOption
WithRejectionResponse return limiterOption. WithRejectionResponse customize the response for the request rejected by the limiter.
func WithSessionKey ¶
WithSessionKey return limiterOption. WithSessionKey config func which defines the request characteristic against the limit is applied
Types ¶
type RejectionResponse ¶
type RejectionResponse struct {
// contains filtered or unexported fields
}
RejectionResponse stores response information for the request rejected by limiter