1
0
Fork 0

chore: update linter

This commit is contained in:
Ludovic Fernandez 2022-08-31 08:24:08 +02:00 committed by GitHub
parent 25027d6df8
commit adf82d72ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 74 additions and 67 deletions

View file

@ -166,6 +166,8 @@ func containsHeader(req *http.Request, name, value string) bool {
// values that are not part of the set of HTTP verbs are replaced with EXTENSION_METHOD.
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
// https://datatracker.ietf.org/doc/html/rfc2616/#section-5.1.1.
//
//nolint:usestdlibvars
func getMethod(r *http.Request) string {
if !utf8.ValidString(r.Method) {
log.WithoutContext().Warnf("Invalid HTTP method encoding: %s", r.Method)

View file

@ -166,7 +166,7 @@ func (rl *rateLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
delay := res.Delay()
if delay > rl.maxDelay {
res.Cancel()
rl.serveDelayError(ctx, w, r, delay)
rl.serveDelayError(ctx, w, delay)
return
}
@ -174,7 +174,7 @@ func (rl *rateLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
rl.next.ServeHTTP(w, r)
}
func (rl *rateLimiter) serveDelayError(ctx context.Context, w http.ResponseWriter, r *http.Request, delay time.Duration) {
func (rl *rateLimiter) serveDelayError(ctx context.Context, w http.ResponseWriter, delay time.Duration) {
w.Header().Set("Retry-After", fmt.Sprintf("%.0f", math.Ceil(delay.Seconds())))
w.Header().Set("X-Retry-In", delay.String())
w.WriteHeader(http.StatusTooManyRequests)