Commit 97d5a733 authored by Filip Grzadkowski's avatar Filip Grzadkowski

Merge pull request #25954 from wojtek-t/max_infligh_limit_logs

Log requests returning TooManyRequests error
parents 31c18258 f3c70ffe
......@@ -119,12 +119,16 @@ func MaxInFlightLimit(c chan bool, longRunningRequestCheck LongRunningRequestChe
defer func() { <-c }()
handler.ServeHTTP(w, r)
default:
tooManyRequests(w)
tooManyRequests(r, w)
}
})
}
func tooManyRequests(w http.ResponseWriter) {
func tooManyRequests(req *http.Request, w http.ResponseWriter) {
// "Too Many Requests" response is returned before logger is setup for the request.
// So we need to explicitly log it here.
defer httplog.NewLogged(req, &w).Log()
// Return a 429 status indicating "Too Many Requests"
w.Header().Set("Retry-After", RetryAfter)
http.Error(w, "Too many requests, please try again later.", errors.StatusTooManyRequests)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment