Group
You can group routes by creating a *Group
struct.
Signature
- app.Group(prefix string, handlers ...func(*Ctx)) *Group
Example
- func main() {
- app := fiber.New()
- 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
- app.Listen(3000)
- }