MCPcopy
hub / github.com/gorilla/mux / URLPath

Method URLPath

route.go:613–631  ·  view source on GitHub ↗

URLPath builds the path part of the URL for a route. See Route.URL(). The route must have a path defined.

(pairs ...string)

Source from the content-addressed store, hash-verified

611//
612// The route must have a path defined.
613func (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.

Callers 1

testRouteFunction · 0.80

Calls 2

prepareVarsMethod · 0.95
urlMethod · 0.80

Tested by 1

testRouteFunction · 0.64