From 6a8ac7a249e34a4f320dd8ff2b346e98f1604e5c Mon Sep 17 00:00:00 2001 From: Simon Hauser Date: Tue, 15 Nov 2022 20:41:02 +0100 Subject: [PATCH] fix: only append MethodOptions as allowed method if HandleOPTIONS is true --- router.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/router.go b/router.go index 1eab403d..818448a4 100644 --- a/router.go +++ b/router.go @@ -439,7 +439,9 @@ func (r *Router) allowed(path, reqMethod string) (allow string) { if len(allowed) > 0 { // Add request method to list of allowed methods - allowed = append(allowed, http.MethodOptions) + if r.HandleOPTIONS { + allowed = append(allowed, http.MethodOptions) + } // Sort allowed methods. // sort.Strings(allowed) unfortunately causes unnecessary allocations