Skip to content

Commit

Permalink
Log requests returning TooManyRequests error
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-t committed May 20, 2016
1 parent ab10484 commit f3c70ff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/apiserver/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f3c70ff

Please sign in to comment.