commit | 2aae7810fa9c8f452d7e51e65601f1030f84d55e | [log] [tgz] |
---|---|---|
author | Javier Provecho Fernandez <javiertitan@gmail.com> | Thu Jan 01 19:44:08 2015 +0100 |
committer | Javier Provecho Fernandez <javiertitan@gmail.com> | Thu Jan 01 19:44:08 2015 +0100 |
tree | 30746f5c94f7d6228dfe8586f6dc6383122ecb89 | |
parent | 91101d17f079ca3c05c6e00354e914a35aa0d3e7 [diff] |
Add support for HTTP 405
diff --git a/router.go b/router.go index 7716dc7..1028c03 100644 --- a/router.go +++ b/router.go
@@ -313,6 +313,18 @@ } } + // Handle 405 + for method, _ := range r.trees { + if method == req.Method { + continue + } + + if handle, _, _ := r.trees[method].getValue(req.URL.Path); handle != nil { + http.Error(w, "405 method not allowed", http.StatusMethodNotAllowed) + return + } + } + // Handle 404 if r.NotFound != nil { r.NotFound(w, req)