👷 fix group.Mount

pull/877/head
kiyon 2020-10-04 00:36:11 +08:00
parent b425a6b25f
commit 839c8f1447
2 changed files with 17 additions and 1 deletions

View File

@ -736,6 +736,22 @@ func Test_App_Group_Invalid(t *testing.T) {
New().Group("/").Use(1)
}
// go test -run Test_App_Group_Mount
func Test_App_Group_Mount(t *testing.T) {
micro := New()
micro.Get("/doe", func(c *Ctx) error {
return c.SendStatus(StatusOK)
})
app := New()
v1 := app.Group("/v1")
v1.Mount("/john", micro)
resp, err := app.Test(httptest.NewRequest("GET", "/v1/john/doe", nil))
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
}
func Test_App_Group(t *testing.T) {
var dummyHandler = testEmptyHandler

View File

@ -23,7 +23,7 @@ func (grp *Group) Mount(prefix string, fiber *App) Router {
for m := range stack {
for r := range stack[m] {
route := grp.app.copyRoute(stack[m][r])
grp.app.addRoute(route.Method, grp.app.addPrefixToRoute(prefix, route))
grp.app.addRoute(route.Method, grp.app.addPrefixToRoute(getGroupPath(grp.prefix, prefix), route))
}
}
return grp