Skip to content

🚀 v3 Request: New ideas for routing and mounting #1829

@balcieren

Description

@balcieren

New Router instead of Group , Route and Mount (should be deprecate)

Express Router

Routing

func UserRouter() *fiber.Router {
	router := fiber.NewRouter()

	router.Get("/", func(c *fiber.Ctx) error {
		return c.JSON("fiber v3")
	})

	return router
}

func main() {
	app := fiber.New()

	app.Use("/user", UserRouter)

	app.Listen(":3000")
}

RouterConfig can contain

router-config


Mounting (#2022)

Express Mount

func main() {
	app := fiber.New()

	user := fiber.New()

	user.Get("/", func(c *fiber.Ctx) error {
		return c.JSON("fiber-v3")
	})

	user.On("mount", func(parent *fiber.App) {
		fmt.Println("user mounted")
	})

	app.Use("/user", user)

	app.Listen(":3000")
}

fiber.Route() (#2065)

Express Route

func main() {
	app := fiber.New()

	app.Route("/events").
		All(func(c *fiber.Ctx) error {
			...
		}).
		Get(func(c *fiber.Ctx) error {
			...
		}).
		Post(func(c *fiber.Ctx) error {
			...
		})

	app.Listen(":3000")
}

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions