mirror of
https://github.com/labstack/echo.git
synced 2025-02-15 13:53:06 +02:00
Fixed group middleware
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
f27e87f36e
commit
64c6d92295
4
echo.go
4
echo.go
@ -224,7 +224,7 @@ const (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// Version of Echo
|
// Version of Echo
|
||||||
Version = "4.1.3"
|
Version = "4.1.4"
|
||||||
website = "https://echo.labstack.com"
|
website = "https://echo.labstack.com"
|
||||||
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
|
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
|
||||||
banner = `
|
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
|
name := filepath.Join(root, path.Clean("/"+p)) // "/"+ for security
|
||||||
return c.File(name)
|
return c.File(name)
|
||||||
}
|
}
|
||||||
get(prefix, h)
|
|
||||||
if prefix == "/" {
|
if prefix == "/" {
|
||||||
return get(prefix+"*", h)
|
return get(prefix+"*", h)
|
||||||
}
|
}
|
||||||
|
|
||||||
return get(prefix+"/*", h)
|
return get(prefix+"/*", h)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
group.go
8
group.go
@ -2,7 +2,6 @@ package echo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -21,12 +20,15 @@ type (
|
|||||||
// Use implements `Echo#Use()` for sub-routes within the Group.
|
// Use implements `Echo#Use()` for sub-routes within the Group.
|
||||||
func (g *Group) Use(middleware ...MiddlewareFunc) {
|
func (g *Group) Use(middleware ...MiddlewareFunc) {
|
||||||
g.middleware = append(g.middleware, middleware...)
|
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
|
// 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.
|
// doesn't find a match, making none of the group middleware process.
|
||||||
for _, p := range []string{"", "/*"} {
|
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)
|
return NotFoundHandler(c)
|
||||||
}, g.middleware...)
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user