aboutsummaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
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)