Skip to content

Commit 4840180

Browse files
authored
fix: only append MethodOptions as allowed method if HandleOPTIONS is true (#360)
1 parent ef8578d commit 4840180

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

router.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,9 @@ func (r *Router) allowed(path, reqMethod string) (allow string) {
439439

440440
if len(allowed) > 0 {
441441
// Add request method to list of allowed methods
442-
allowed = append(allowed, http.MethodOptions)
442+
if r.HandleOPTIONS {
443+
allowed = append(allowed, http.MethodOptions)
444+
}
443445

444446
// Sort allowed methods.
445447
// sort.Strings(allowed) unfortunately causes unnecessary allocations

0 commit comments

Comments
 (0)