URL generates a URL from the route path and parameters. This method fills in the route parameters with the provided values. Parameter matching respects the app's CaseSensitive configuration: case-insensitive by default, case-sensitive when CaseSensitive is true. Example: app.Get("/user/:name/:id"
(params Map)
| 86 | // |
| 87 | //nolint:gocritic // hugeParam: app.GetRoute returns a value, so URL must be callable on that value directly. |
| 88 | func (r Route) URL(params Map) (string, error) { |
| 89 | if r.Path == "" { |
| 90 | return "", ErrNotFound |
| 91 | } |
| 92 | |
| 93 | return buildRouteURL(&r, params) |
| 94 | } |
| 95 | |
| 96 | // buildRouteURL generates a URL from route segments and parameters. |
| 97 | // This shared helper is used by both Route.URL() and DefaultRes.getLocationFromRoute() |