1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

Fixed group middleware

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2019-04-29 16:46:08 -07:00
parent f27e87f36e
commit 64c6d92295
2 changed files with 6 additions and 6 deletions

View File

@ -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)
}

View File

@ -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...)
})
}
}