fix the unnecessary pass through for routes with groups

pull/487/head
wernerr 2020-06-19 10:54:15 +02:00
parent 20b2c82ede
commit f1710ea1b6
2 changed files with 20 additions and 1 deletions

View File

@ -525,6 +525,25 @@ func Test_App_Group(t *testing.T) {
//utils.AssertEqual(t, "/test/v1/users", resp.Header.Get("Location"), "Location")
}
func Test_App_Deep_Group(t *testing.T) {
runThroughCount := 0
var dummyHandler = func(c *Ctx) {
runThroughCount++
c.Next()
}
app := New()
gApi := app.Group("/api", dummyHandler)
gV1 := gApi.Group("/v1", dummyHandler)
gUser := gV1.Group("/user", dummyHandler)
gUser.Get("/authenticate", func(ctx *Ctx) {
runThroughCount++
ctx.SendStatus(200)
})
testStatus200(t, app, "/api/v1/user/authenticate", "GET")
utils.AssertEqual(t, 4, runThroughCount, "Loop count")
}
func Test_App_Listen(t *testing.T) {
app := New(&Settings{
DisableStartupMessage: true,

View File

@ -108,5 +108,5 @@ func (grp *Group) Group(prefix string, handlers ...Handler) *Group {
if len(handlers) > 0 {
grp.app.register("USE", prefix, handlers...)
}
return grp.app.Group(prefix, handlers...)
return grp.app.Group(prefix)
}