mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-03 21:17:33 +08:00
cleanup (log): rate limit logs
This commit is contained in:
@ -137,9 +137,10 @@ var limiter = rate.NewLimiter(10, 1000)
|
||||
func RateLimiter(fn func(*App, http.ResponseWriter, *http.Request)) func(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||
return func(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||
if limiter.Allow() == false {
|
||||
Log.Warning("middleware::http::ratelimit too many requests")
|
||||
SendErrorResult(
|
||||
res,
|
||||
NewError(http.StatusText(429), http.StatusTooManyRequests),
|
||||
NewError(http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user