Throw 405 if !handleOPTIONS and no OPTIONS handler set (#201)
diff --git a/router.go b/router.go
index bfd4db0..558e139 100644
--- a/router.go
+++ b/router.go
@@ -366,13 +366,11 @@
}
}
- if req.Method == "OPTIONS" {
+ if req.Method == "OPTIONS" && r.HandleOPTIONS {
// Handle OPTIONS requests
- if r.HandleOPTIONS {
- if allow := r.allowed(path, req.Method); len(allow) > 0 {
- w.Header().Set("Allow", allow)
- return
- }
+ if allow := r.allowed(path, req.Method); len(allow) > 0 {
+ w.Header().Set("Allow", allow)
+ return
}
} else {
// Handle 405