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 != "" {