mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
app/vmauth: use slices.Contains() instead of hasInt()
This commit is contained in:
parent
76a6f806ae
commit
96f913c83e
1 changed files with 2 additions and 10 deletions
|
@ -13,6 +13,7 @@ import (
|
||||||
"net/textproto"
|
"net/textproto"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -271,7 +272,7 @@ func tryProcessingRequest(w http.ResponseWriter, r *http.Request, targetURL *url
|
||||||
logger.Warnf("remoteAddr: %s; requestURI: %s; retrying the request to %s because of response error: %s", remoteAddr, req.URL, targetURL, err)
|
logger.Warnf("remoteAddr: %s; requestURI: %s; retrying the request to %s because of response error: %s", remoteAddr, req.URL, targetURL, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if hasInt(retryStatusCodes, res.StatusCode) {
|
if slices.Contains(retryStatusCodes, res.StatusCode) {
|
||||||
_ = res.Body.Close()
|
_ = res.Body.Close()
|
||||||
if !rtbOK || !rtb.canRetry() {
|
if !rtbOK || !rtb.canRetry() {
|
||||||
// If we get an error from the retry_status_codes list, but cannot execute retry,
|
// If we get an error from the retry_status_codes list, but cannot execute retry,
|
||||||
|
@ -313,15 +314,6 @@ func tryProcessingRequest(w http.ResponseWriter, r *http.Request, targetURL *url
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasInt(a []int, n int) bool {
|
|
||||||
for _, x := range a {
|
|
||||||
if x == n {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
var copyBufPool bytesutil.ByteBufferPool
|
var copyBufPool bytesutil.ByteBufferPool
|
||||||
|
|
||||||
func copyHeader(dst, src http.Header) {
|
func copyHeader(dst, src http.Header) {
|
||||||
|
|
Loading…
Reference in a new issue