Skip to content

Commit adbc77e

Browse files
tniswongjulienschmidt
authored andcommitted
Throw 405 if !handleOPTIONS and no OPTIONS handler set (#201)
1 parent 5aa29e8 commit adbc77e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

router.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,11 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
366366
}
367367
}
368368

369-
if req.Method == "OPTIONS" {
369+
if req.Method == "OPTIONS" && r.HandleOPTIONS {
370370
// Handle OPTIONS requests
371-
if r.HandleOPTIONS {
372-
if allow := r.allowed(path, req.Method); len(allow) > 0 {
373-
w.Header().Set("Allow", allow)
374-
return
375-
}
371+
if allow := r.allowed(path, req.Method); len(allow) > 0 {
372+
w.Header().Set("Allow", allow)
373+
return
376374
}
377375
} else {
378376
// Handle 405

0 commit comments

Comments
 (0)