-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🤗 a not intuitive group middleware matching problem #1920
Comments
Yes right https://github.com/gofiber/fiber/blob/master/group.go#L179 I think express is working like the same or? |
Concept of real groups does not exist in express, they are just grouped paths that are checked in the order they are declared. |
In fact I'd sugestion buth Behavior changeJust for me, I think it would be better to understand if group middlware is scoped: group := app.Group(prefix, middleware)
group.Get(path, handler)
group.Get(path2, handler2) middleware's behavior is like this: group := app.Group(prefix)
group.Get(path, middleware, handler)
group.Get(path2, middleware, handler2) NOT: app.Use(prefix, middleware)
group := app.Group(prefix)
group.Get(path, handler)
group.Get(path2, handler2) additional documentationthis can be avoid by add tailing slash to group prefix: g1 := app.Group("/p/", middleware)
g2 := app.Group("/page/", middleware) this won't change final request paths but can aviod group middleware match other group's request, as long as users don't create multiple group with same prefix. |
We will think about it. |
have tested this and it does not fix the problem g1 := app.Group("/p/", middleware)
g2 := app.Group("/page/", middleware) otherwise i would have put this kind of solution in the group method |
by “fix” I mean all router with |
and as for document, I mean that mention group middleware is |
Question description
I'm using
App.Group()
with middleware but I found a middleware add in group A may match request to group B.This may not be a bug because prefix
/p
indeed should match path/page
, but it would be more intuitive if these middleware are only group-wide.I'm guesing
app.Group(prefix, middleware)
is working just likeapp.Use(prefix, middleware)
?Code snippet Optional
you will see output
"group '/p"
and"group '/page"
in this example:The text was updated successfully, but these errors were encountered: