rpc: use slices.Contains

Signed-off-by: deepdring <deepdrink@icloud.com>
This commit is contained in:
deepdring 2025-08-14 22:39:10 +08:00
parent 2dbb580f51
commit b8c237aea8

View file

@ -27,6 +27,7 @@ import (
"mime" "mime"
"net/http" "net/http"
"net/url" "net/url"
"slices"
"strconv" "strconv"
"sync" "sync"
"time" "time"
@ -351,10 +352,8 @@ func (s *Server) validateRequest(r *http.Request) (int, error) {
} }
// Check content-type // Check content-type
if mt, _, err := mime.ParseMediaType(r.Header.Get("content-type")); err == nil { if mt, _, err := mime.ParseMediaType(r.Header.Get("content-type")); err == nil {
for _, accepted := range acceptedContentTypes { if slices.Contains(acceptedContentTypes, mt) {
if accepted == mt { return 0, nil
return 0, nil
}
} }
} }
// Invalid content-type // Invalid content-type