Skip to content

Subgroups with middlewares are overriding parent groups middlewares #17

@es-lab

Description

@es-lab

Hi @joeybloggs ,

I'm doing some testing with this router, and I found an issue.
Here is an example:

a := server.Group("/a", aM)
a.Get("/test", func(ctx *internal.Ctx) {
	ctx.JSON(http.StatusOK, "a-ok")
})

b := a.Group("/b", bM)
b.Get("/test", func(ctx *internal.Ctx) {
	ctx.JSON(http.StatusOK, "b-ok")
})

c := b.Group("/c", cM)
c.Get("/test", func(ctx *internal.Ctx) {
	ctx.JSON(http.StatusOK, "c-ok")
})
func aM(ctx *internal.Ctx) {
	ctx.Next()
}

func bM(ctx *internal.Ctx) {
	ctx.Next()
}

func cM(ctx *internal.Ctx) {
	ctx.Next()
}

And this is the behavior:

  1. /a/test executes the aM. Everthing OK.
  2. /a/b/test executes only bM, it does not execute aM. But it should.
  3. /a/b/c/test executes only cM, it does not execute aM and bM. But it should execute them all.

If this is a bug, I hope it will be fixed ASAP. From a lot of routers out there this one seems pretty good to me, and this issue is blocking me to migrate to it.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions