Skip to content
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

🔥 app.Group seems impossible to nest multiple layers #155

Closed
hyingreborn opened this issue Feb 18, 2020 · 1 comment
Closed

🔥 app.Group seems impossible to nest multiple layers #155

hyingreborn opened this issue Feb 18, 2020 · 1 comment

Comments

@hyingreborn
Copy link

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

@Fenny
Copy link
Member

Fenny commented Feb 19, 2020

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
}

@Fenny Fenny added the solved label Feb 20, 2020
@Fenny Fenny added this to the 🔣 Fiber v2 milestone Feb 20, 2020
@Fenny Fenny closed this as completed Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants