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

Method URLHost

route.go:585–608  ·  view source on GitHub ↗

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

(pairs ...string)

Source from the content-addressed store, hash-verified

583//
584// The route must have a host defined.
585func (r *Route) URLHost(pairs ...string) (*url.URL, error) {
586 if r.err != nil {
587 return nil, r.err
588 }
589 if r.regexp.host == nil {
590 return nil, errors.New("mux: route doesn't have a host")
591 }
592 values, err := r.prepareVars(pairs...)
593 if err != nil {
594 return nil, err
595 }
596 host, err := r.regexp.host.url(values)
597 if err != nil {
598 return nil, err
599 }
600 u := &url.URL{
601 Scheme: "http",
602 Host: host,
603 }
604 if r.buildScheme != "" {
605 u.Scheme = r.buildScheme
606 }
607 return u, nil
608}
609
610// URLPath builds the path part of the URL for a route. See Route.URL().
611//

Callers 1

testRouteFunction · 0.80

Calls 2

prepareVarsMethod · 0.95
urlMethod · 0.80

Tested by 1

testRouteFunction · 0.64