Documentation
¶
Index ¶
- func NewApiMiddleware(f LimitFunc, resource string) gin.HandlerFunc
- func NewHttpMiddleware(f LimitFunc, resource string) middlewares.Middleware
- type LimitFunc
- type LimiterFactory
- type Registry
- func (r *Registry) GC()
- func (r *Registry) Limit(ctx context.Context, resource string) error
- func (r *Registry) LimitN(ctx context.Context, resource string, n int) error
- func (r *Registry) Remove(resource, group string)
- func (r *Registry) RemoveAll()
- func (r *Registry) RemoveBatch(items map[string]map[string]bool)
- func (r *Registry) ScheduleGC(interval time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewApiMiddleware ¶
func NewApiMiddleware(f LimitFunc, resource string) gin.HandlerFunc
NewApiMiddleware creates middleware to limit request rate for REST API.
func NewHttpMiddleware ¶
func NewHttpMiddleware(f LimitFunc, resource string) middlewares.Middleware
NewHttpMiddleware creates middleware to limit HTTP request rate.
Types ¶
type LimiterFactory ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry(factory LimiterFactory) *Registry
func (*Registry) Limit ¶
Limit limits request rate according to HTTP request context. Note, it requires to hook IP/API key middlewares for HTTP server.
func (*Registry) LimitN ¶ added in v0.2.1
Limit limits request rate according to HTTP request context. Note, it requires to hook IP/API key middlewares for HTTP server.
func (*Registry) ScheduleGC ¶
Click to show internal directories.
Click to hide internal directories.