Skip to content
1.5.2
The Basics / 1.5.2

Routing

Andurel keeps route declarations separate from controller registration and provides typed URL helpers for application links.

Declare a route

Routes live under router/routes:

1var ProductShow = routing.NewRouteWithUUIDID(
2    "/products/:id",
3    "products.show",
4    "",
5)

Use the generated helper instead of hard-coding application URLs:

1routes.ProductShow.URL(product.ID)

Register a route

Controllers register Echo routes with the shared router:

1_, err := r.AddRoute(echo.Route{
2    Method:  http.MethodGet,
3    Path:    routes.ProductShow.Path(),
4    Name:    routes.ProductShow.Name(),
5    Handler: p.Show,
6})

Inspect routes

Use the CLI to inspect route names, paths, parameters, and source files:

1andurel routes
2andurel routes --json

Inertia projects can generate TypeScript URL helpers with andurel generate routes.

Documentation

Start typing to search the documentation.