summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/group.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/labstack/echo/group.go')
-rw-r--r--vendor/github.com/labstack/echo/group.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/vendor/github.com/labstack/echo/group.go b/vendor/github.com/labstack/echo/group.go
index 6ae32372..f7e61a2e 100644
--- a/vendor/github.com/labstack/echo/group.go
+++ b/vendor/github.com/labstack/echo/group.go
@@ -20,9 +20,11 @@ func (g *Group) Use(middleware ...MiddlewareFunc) {
g.middleware = append(g.middleware, middleware...)
// 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.
- g.echo.Any(path.Clean(g.prefix+"/*"), func(c Context) error {
- return NotFoundHandler(c)
- }, g.middleware...)
+ for _, p := range []string{"", "/*"} {
+ g.echo.Any(path.Clean(g.prefix+p), func(c Context) error {
+ return NotFoundHandler(c)
+ }, g.middleware...)
+ }
}
// CONNECT implements `Echo#CONNECT()` for sub-routes within the Group.
@@ -71,17 +73,21 @@ func (g *Group) TRACE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
}
// Any implements `Echo#Any()` for sub-routes within the Group.
-func (g *Group) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) {
- for _, m := range methods {
- g.Add(m, path, handler, middleware...)
+func (g *Group) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route {
+ routes := make([]*Route, len(methods))
+ for i, m := range methods {
+ routes[i] = g.Add(m, path, handler, middleware...)
}
+ return routes
}
// Match implements `Echo#Match()` for sub-routes within the Group.
-func (g *Group) Match(methods []string, path string, handler HandlerFunc, middleware ...MiddlewareFunc) {
- for _, m := range methods {
- g.Add(m, path, handler, middleware...)
+func (g *Group) Match(methods []string, path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route {
+ routes := make([]*Route, len(methods))
+ for i, m := range methods {
+ routes[i] = g.Add(m, path, handler, middleware...)
}
+ return routes
}
// Group creates a new sub-group with prefix and optional sub-group-level middleware.