chore: update linter
This commit is contained in:
parent
25027d6df8
commit
adf82d72ae
23 changed files with 74 additions and 67 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue