diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2025-05-25 09:31:58 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2025-05-25 09:31:58 +0100 |
| commit | bca1b0ccdece7b992cc88712aca36a9a127b1381 (patch) | |
| tree | a91d7028610d66c8f8f52bde5bbb3aeb41c3ff1f /http.go | |
| parent | 64fe7a6ad302af4d9b35c86f262c4ff41ed980fd (diff) | |
Use modern APIs and retire MapKeys
Diffstat (limited to 'http.go')
| -rw-r--r-- | http.go | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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) |
