Documentation ¶
Overview ¶
Package middleware defines possible middleware that can be used by router
Index ¶
Constants ¶
View Source
const ( // ExpiryTime defines how long before the user got deleted ExpiryTime time.Duration = 3 * time.Minute // RefreshRate deinfes how often we check the map for expired user RefreshRate time.Duration = 2 * time.Minute // AvgRate defines the limit of average token comsumption AvgRate rate.Limit = 1 // MaxRate defines the limit of spike token consumption MaxRate int = 1 )
Variables ¶
This section is empty.
Functions ¶
func LogRoute ¶
LogRoute prettyprints requested routes
GET /v1/<endpoints> -> r.RequestURI LogRoute() -> [GET] : 127.0.0.1/api/v1/<endpoints>
func RateLimit ¶
func RateLimit(req http.HandlerFunc) http.HandlerFunc
RateLimit is the middleware to prevent a single IP to overload the server by performing too many req
Types ¶
Click to show internal directories.
Click to hide internal directories.