URLPath builds the path part of the URL for a route. See Route.URL(). The route must have a path defined.
(pairs ...string)
| 611 | // |
| 612 | // The route must have a path defined. |
| 613 | func (r *Route) URLPath(pairs ...string) (*url.URL, error) { |
| 614 | if r.err != nil { |
| 615 | return nil, r.err |
| 616 | } |
| 617 | if r.regexp.path == nil { |
| 618 | return nil, errors.New("mux: route doesn't have a path") |
| 619 | } |
| 620 | values, err := r.prepareVars(pairs...) |
| 621 | if err != nil { |
| 622 | return nil, err |
| 623 | } |
| 624 | path, err := r.regexp.path.url(values) |
| 625 | if err != nil { |
| 626 | return nil, err |
| 627 | } |
| 628 | return &url.URL{ |
| 629 | Path: path, |
| 630 | }, nil |
| 631 | } |
| 632 | |
| 633 | // GetPathTemplate returns the template used to build the |
| 634 | // route match. |