From 885c0678ff368a5fd577c3822ffdf15b51f02965 Mon Sep 17 00:00:00 2001 From: astaxie Date: Mon, 4 Aug 2014 16:21:34 +0800 Subject: [PATCH] move filter wrong http method --- router.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/router.go b/router.go index 254e8cd7..d24241e6 100644 --- a/router.go +++ b/router.go @@ -578,6 +578,13 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) return false } + // filter wrong httpmethod + if _, ok := HTTPMETHOD[r.Method]; !ok { + http.Error(w, "Method Not Allowed", 405) + goto Admin + } + + // filter for static file if do_filter(BeforeStatic) { goto Admin } @@ -595,11 +602,6 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) }() } - if _, ok := HTTPMETHOD[r.Method]; !ok { - http.Error(w, "Method Not Allowed", 405) - goto Admin - } - if r.Method != "GET" && r.Method != "HEAD" { if CopyRequestBody && !context.Input.IsUpload() { context.Input.CopyBody()