1
0
mirror of https://github.com/labstack/echo.git synced 2025-02-19 19:10:29 +02:00

fixed default routes for group

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-10-29 22:54:06 -07:00
parent 8b8aac8aef
commit 58166d599b

View File

@ -17,10 +17,15 @@ func (g *Group) Use(middleware ...MiddlewareFunc) {
// Allow requests `/prefix & /prefix/*` to reach the group as they might get // Allow requests `/prefix & /prefix/*` to reach the group as they might get
// dropped if router doesn't find a match, making none of the group middleware // dropped if router doesn't find a match, making none of the group middleware
// execute. // execute.
paths := []string{"/*"}
if g.prefix == "" { if g.prefix == "" {
g.Any("/", NotFoundHandler, g.middleware...) paths = append(paths, "/")
} else {
paths = append(paths, "")
}
for _, p := range paths {
g.Any(p, NotFoundHandler, g.middleware...)
} }
g.Any("/*", NotFoundHandler, g.middleware...)
} }
// CONNECT implements `Echo#CONNECT()` for sub-routes within the Group. // CONNECT implements `Echo#CONNECT()` for sub-routes within the Group.