From bca1b0ccdece7b992cc88712aca36a9a127b1381 Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sun, 25 May 2025 09:31:58 +0100 Subject: Use modern APIs and retire MapKeys --- http.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'http.go') diff --git a/http.go b/http.go index 8b57133..8fd89a9 100644 --- a/http.go +++ b/http.go @@ -5,6 +5,7 @@ package core import ( "net/http" + "slices" "sort" "strings" ) @@ -36,10 +37,8 @@ func FilterHTTPMethod(methods ...string) HTTPFilterFunc { sort.Strings(methods) allowed := strings.Join(methods, ", ") return func(w http.ResponseWriter, req *http.Request) bool { - for _, method := range methods { - if method == req.Method { - return false - } + if slices.Contains(methods, req.Method) { + return false } w.Header().Set("Allow", allowed) w.WriteHeader(http.StatusMethodNotAllowed) -- cgit v1.2.3-70-g09d2