Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultErrorHandler ¶
DefaultErrorHandler is the default ErrorHandler used by a new Middleware.
func DefaultLimitReachedHandler ¶
DefaultLimitReachedHandler is the default LimitReachedHandler used by a new Middleware.
func NewMiddleware ¶
func NewMiddleware(limiter *limiter.Limiter, options ...Option) gin.HandlerFunc
NewMiddleware return a new instance of a basic HTTP middleware.
Types ¶
type ErrorHandler ¶
ErrorHandler is an handler used to inform when an error has occurred.
type LimitReachedHandler ¶
LimitReachedHandler is an handler used to inform when the limit has exceeded.
type Middleware ¶
type Middleware struct { Limiter *limiter.Limiter OnError ErrorHandler OnLimitReached LimitReachedHandler }
Middleware is the middleware for basic http.Handler.
func (*Middleware) Handle ¶
func (middleware *Middleware) Handle(c *gin.Context)
Handle gin request.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to define Middleware configuration.
func WithErrorHandler ¶
func WithErrorHandler(handler ErrorHandler) Option
WithErrorHandler will configure the Middleware to use the given ErrorHandler.
func WithLimitReachedHandler ¶
func WithLimitReachedHandler(handler LimitReachedHandler) Option
WithLimitReachedHandler will configure the Middleware to use the given LimitReachedHandler.