-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send "Retry-After" to comply with RFC6585 #141
Conversation
Also use Golang const for HTTP status
ratelimit/tokenlimiter.go
Outdated
@@ -180,8 +180,8 @@ type RateErrHandler struct { | |||
|
|||
func (e *RateErrHandler) ServeHTTP(w http.ResponseWriter, req *http.Request, err error) { | |||
if rerr, ok := err.(*MaxRateError); ok { | |||
w.Header().Set("X-Retry-In", rerr.delay.String()) | |||
w.WriteHeader(429) | |||
w.Header().Set("Retry-After", fmt.Sprintf("%.0f", rerr.delay.Seconds())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid breaking, you must keep X-Retry-In
for backward compatibility.
@herver could you rebase on master ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is related to #139.
It makes sure we send the Retry-After "hint" in the correct format.