Skip to content

🚀 [v3 Feature Request]: Grouping - altered middleware behavior #2200

@acidjazz

Description

@acidjazz

Feature Description

  • V2 Grouping should be renamed Prefixing - and solely the ability to define a prefix, not actual grouping
  • Grouping should work somewhat how V2 Grouping works, but does not require a prefix

ex: defining a group

authRoutes := app.Group(middleware.Auth)
authRoutes.Get("/me", controllers.AuthMe)

ex: defining a group with a prefix

authRoutes := app.Group(middleware.Auth).Prefix("/auth")
authRoutes.Get("/me", controllers.AuthMe)
  • CHANGE: Grouped middleware should be given the context of each individual route, not the groups route
package middleware

func Auth(c *fiber.Ctx) {
  c.Route() // should be /auth/me - NOT /auth (currently in v2)
}

Other Notes

  • v2 grouping currently adds routes, a GET for each group - this is not neccessary
  • All middleware in groups should only executed w/ the exact context of the routes defined w/in the group

other ideas of grouping

app.Prefix("/auth").Group(middleware.Auth, func(app *fiber.App) {
  app.Get("/me", controllers.AuthMe)
})

I like the 1st example more - just more ideas

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my suggestion prior to opening this one.
  • I understand that improperly formatted feature requests may be closed without explanation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions