Route redirects to the Route registered in the app with appropriate parameters. If you want to send queries or params to route, you should use config parameter.
(name string, config ...RedirectConfig)
| 340 | // Route redirects to the Route registered in the app with appropriate parameters. |
| 341 | // If you want to send queries or params to route, you should use config parameter. |
| 342 | func (r *Redirect) Route(name string, config ...RedirectConfig) error { |
| 343 | // Check config |
| 344 | cfg := RedirectConfig{} |
| 345 | if len(config) > 0 { |
| 346 | cfg = config[0] |
| 347 | } |
| 348 | |
| 349 | // Get location from route name |
| 350 | route := r.c.App().GetRoute(name) |
| 351 | location, err := r.c.getLocationFromRoute(&route, cfg.Params) |
| 352 | if err != nil { |
| 353 | return err |
| 354 | } |
| 355 | |
| 356 | // Check queries |
| 357 | if len(cfg.Queries) > 0 { |
| 358 | queryText := bytebufferpool.Get() |
| 359 | defer bytebufferpool.Put(queryText) |
| 360 | |
| 361 | first := true |
| 362 | for k, v := range cfg.Queries { |
| 363 | if !first { |
| 364 | queryText.WriteByte('&') |
| 365 | } |
| 366 | first = false |
| 367 | queryText.WriteString(k) |
| 368 | queryText.WriteByte('=') |
| 369 | queryText.WriteString(v) |
| 370 | } |
| 371 | |
| 372 | return r.To(location + "?" + r.c.app.toString(queryText.Bytes())) |
| 373 | } |
| 374 | |
| 375 | return r.To(location) |
| 376 | } |
| 377 | |
| 378 | // Back redirect to the URL to referer. |
| 379 | // It validates that the Referer is same-origin to prevent open redirect attacks. |
nothing calls this directly
no test coverage detected