Skip to content

Commit 64c6d92

Browse files
committed
Fixed group middleware
Signed-off-by: Vishal Rana <[email protected]>
1 parent f27e87f commit 64c6d92

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

echo.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ const (
224224

225225
const (
226226
// Version of Echo
227-
Version = "4.1.3"
227+
Version = "4.1.4"
228228
website = "https://echo.labstack.com"
229229
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
230230
banner = `
@@ -472,11 +472,9 @@ func (common) static(prefix, root string, get func(string, HandlerFunc, ...Middl
472472
name := filepath.Join(root, path.Clean("/"+p)) // "/"+ for security
473473
return c.File(name)
474474
}
475-
get(prefix, h)
476475
if prefix == "/" {
477476
return get(prefix+"*", h)
478477
}
479-
480478
return get(prefix+"/*", h)
481479
}
482480

group.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package echo
22

33
import (
44
"net/http"
5-
"path"
65
)
76

87
type (
@@ -21,12 +20,15 @@ type (
2120
// Use implements `Echo#Use()` for sub-routes within the Group.
2221
func (g *Group) Use(middleware ...MiddlewareFunc) {
2322
g.middleware = append(g.middleware, middleware...)
23+
if len(g.middleware) == 0 {
24+
return
25+
}
2426
// Allow all requests to reach the group as they might get dropped if router
2527
// doesn't find a match, making none of the group middleware process.
2628
for _, p := range []string{"", "/*"} {
27-
g.Any(path.Clean(g.prefix+p), func(c Context) error {
29+
g.Any(p, func(c Context) error {
2830
return NotFoundHandler(c)
29-
}, g.middleware...)
31+
})
3032
}
3133
}
3234

0 commit comments

Comments
 (0)