aboutsummaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2025-05-25 09:31:58 +0100
committerGrégoire Duchêne <gduchene@awhk.org>2025-05-25 09:31:58 +0100
commitbca1b0ccdece7b992cc88712aca36a9a127b1381 (patch)
treea91d7028610d66c8f8f52bde5bbb3aeb41c3ff1f /http.go
parent64fe7a6ad302af4d9b35c86f262c4ff41ed980fd (diff)
Use modern APIs and retire MapKeys
Diffstat (limited to 'http.go')
-rw-r--r--http.go7
1 files changed, 3 insertions, 4 deletions
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)