From 5dee6b7d19f216b3e8790673f8ba10f6d8d30652 Mon Sep 17 00:00:00 2001 From: astaxie Date: Wed, 28 May 2014 10:23:31 +0800 Subject: [PATCH] beego: fix the namespace cond --- namespace.go | 1 + router.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/namespace.go b/namespace.go index 89edbbcc..5eda7281 100644 --- a/namespace.go +++ b/namespace.go @@ -191,6 +191,7 @@ func (n *Namespace) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } if n.condition != nil && !n.condition(context) { http.Error(rw, "Method Not Allowed", 405) + return } n.handlers.ServeHTTP(rw, r) } diff --git a/router.go b/router.go index 632e8f4f..a3ca9656 100644 --- a/router.go +++ b/router.go @@ -763,6 +763,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) if !findrouter { for _, route := range p.fixrouters { n := len(requestPath) + if n == 0 { + continue + } if requestPath == route.pattern { runMethod = p.getRunMethod(r.Method, context, route) if runMethod != "" {