From 64c6d9229525121028ad25b8cc49c81ce8b09ea6 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Mon, 29 Apr 2019 16:46:08 -0700 Subject: [PATCH] Fixed group middleware Signed-off-by: Vishal Rana --- echo.go | 4 +--- group.go | 8 +++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/echo.go b/echo.go index e54100266..fd918c165 100644 --- a/echo.go +++ b/echo.go @@ -224,7 +224,7 @@ const ( const ( // Version of Echo - Version = "4.1.3" + Version = "4.1.4" website = "https://echo.labstack.com" // http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo banner = ` @@ -472,11 +472,9 @@ func (common) static(prefix, root string, get func(string, HandlerFunc, ...Middl name := filepath.Join(root, path.Clean("/"+p)) // "/"+ for security return c.File(name) } - get(prefix, h) if prefix == "/" { return get(prefix+"*", h) } - return get(prefix+"/*", h) } diff --git a/group.go b/group.go index e674cad4f..7f57db465 100644 --- a/group.go +++ b/group.go @@ -2,7 +2,6 @@ package echo import ( "net/http" - "path" ) type ( @@ -21,12 +20,15 @@ type ( // Use implements `Echo#Use()` for sub-routes within the Group. func (g *Group) Use(middleware ...MiddlewareFunc) { g.middleware = append(g.middleware, middleware...) + if len(g.middleware) == 0 { + return + } // Allow all requests to reach the group as they might get dropped if router // doesn't find a match, making none of the group middleware process. for _, p := range []string{"", "/*"} { - g.Any(path.Clean(g.prefix+p), func(c Context) error { + g.Any(p, func(c Context) error { return NotFoundHandler(c) - }, g.middleware...) + }) } }