From b8c237aea8f5a746d66c6c05244e8298f5978e8a Mon Sep 17 00:00:00 2001 From: deepdring Date: Thu, 14 Aug 2025 22:39:10 +0800 Subject: [PATCH] rpc: use slices.Contains Signed-off-by: deepdring --- rpc/http.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rpc/http.go b/rpc/http.go index f4b99429ef..48cb22edee 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -27,6 +27,7 @@ import ( "mime" "net/http" "net/url" + "slices" "strconv" "sync" "time" @@ -351,10 +352,8 @@ func (s *Server) validateRequest(r *http.Request) (int, error) { } // Check content-type if mt, _, err := mime.ParseMediaType(r.Header.Get("content-type")); err == nil { - for _, accepted := range acceptedContentTypes { - if accepted == mt { - return 0, nil - } + if slices.Contains(acceptedContentTypes, mt) { + return 0, nil } } // Invalid content-type