Fiber: 馃敟 app.Group seems impossible to nest multiple layers

Created on 18 Feb 2020  路  1Comment  路  Source: gofiber/fiber

Is your feature request related to a problem?
app.Group seems impossible to nest multiple layers like gin

Describe the solution you'd like

//my api module
apiRouter := app.Group("/api")
{
    authRouter := apiRouter.Group("/auth")
    {
        authRouter.POST("/login", auth.Login)
        authRouter.GET("/tokenRefresh", middleware.JWTAuth(), auth.TokenRefresh)
    }
    v1Router := apiRouter.Group("/v1", middleware.JWTAuth())
    {
        managerRouter := v1Router.Group("/managers")
        {
            managerRouter.POST("", manager.Add)
        }
        testRouter := v1Router.Group("/test")
        {
            testRouter.GET("/redisSet", test.RedisSet)
        }
    }
    v2Router := apiRouter.Group("/v2")
    {
        managerRouter := v2Router.Group("/manager")
        {
            managerRouter.POST("/add", v2manager.Add)
        }
    }
}

Describe alternatives you've considered

Additional context

Most helpful comment

Group chaining will be available in v2 https://github.com/gofiber/fiber/issues/92
PS: In v2 you can also provide middleware handlers to the group

func main() {
  api := app.Group("/api", cors())  // /api

  v1 := api.Group("/v1", mysql())   // /api/v1
  v1.Get("/list", handler)          // /api/v1/list
  v1.Get("/user", handler)          // /api/v1/user

  v2 := api.Group("/v2", mongodb()) // /api/v2
  v2.Get("/list", handler)          // /api/v2/list
  v2.Get("/user", handler)          // /api/v2/user
}

>All comments

Group chaining will be available in v2 https://github.com/gofiber/fiber/issues/92
PS: In v2 you can also provide middleware handlers to the group

func main() {
  api := app.Group("/api", cors())  // /api

  v1 := api.Group("/v1", mysql())   // /api/v1
  v1.Get("/list", handler)          // /api/v1/list
  v1.Get("/user", handler)          // /api/v1/user

  v2 := api.Group("/v2", mongodb()) // /api/v2
  v2.Get("/list", handler)          // /api/v2/list
  v2.Get("/user", handler)          // /api/v2/user
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

renatojf picture renatojf  路  3Comments

jeyraj picture jeyraj  路  4Comments

peterbourgon picture peterbourgon  路  4Comments

petersephrin picture petersephrin  路  4Comments

bashery picture bashery  路  4Comments