Add a Retry-After header when rate limit is exceeded

This commit is contained in:
Satnam Singh
2015-01-21 17:12:07 -08:00
parent b5bc0c1619
commit 8350bb9700
2 changed files with 19 additions and 0 deletions

View File

@@ -72,6 +72,7 @@ func RateLimit(rl util.RateLimiter, handler http.Handler) http.Handler {
return
}
w.WriteHeader(http.StatusServiceUnavailable)
w.Header().Set("Retry-After", "1")
fmt.Fprintf(w, "Rate limit exceeded.")
})
}