// Host registers a new route with a matcher for the URL host.
// See Route.Host().
511429
func (r *Router) Host(tpl string) *Route {
	return r.NewRoute().Host(tpl)
}
584459
func Host(host string) ConnectOption {
	return func(c *httpclient.HttpClient) {
		c.Host = host
	}
}
313683
func (h *Host) String() string {
	return net.JoinHostPort(h.Name, strconv.Itoa(h.Port))
}
120971
func (p *PerHost) AddHost(host string) {
	if strings.HasSuffix(host, ".") {
		host = host[:len(host)-1]
	}
	p.bypassHosts = append(p.bypassHosts, host)
}
141062
func (s *HostService) AddHost(p *AddHostParams) (*AddHostResponse, error) {
	resp, err := s.cs.newRequest("addHost", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r AddHostResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
602723
func (api *API) Hosts(ctx context.Context) []*Node {
	span, _ := tracing.StartSpanFromContext(ctx, "API.Hosts")
	defer span.Finish()
	return api.cluster.Nodes()
}
1279700
func Provider(host string) string {
	for provider, regex := range providerRegex {
		if regex.MatchString(host) {
			return provider
		}
	}

	return ""
}
1291134
func (h *Host) Copy(c *Host) {
	h.Hostname = c.Hostname
	h.IPv4Addr = copyIP(c.IPv4Addr)
	h.IPv4Mask = copyIPMask(c.IPv4Mask)
	h.IPv6Addr = copyIP(c.IPv6Addr)
	h.IPv6Mask = copyIPMask(c.IPv6Mask)
}
449267
func (cs Credentials) Hosts() []string {
	hosts := []string{}
	for host := range cs.m {
		hosts = append(hosts, host)
	}
	return hosts
}
1075057
func (api *API) HostGetByHost(host string) (res *Host, err error) {
	hosts, err := api.HostsGet(Params{"filter": map[string]string{"host": host}})
	if err != nil {
		return
	}

	if len(hosts) == 1 {
		res = &hosts[0]
	} else {
		e := ExpectedOneResult(len(hosts))
		err = &e
	}
	return
}
621095
func (h *Host) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	suffix := httputil.PathSuffix(r)
	seg := strings.Split(suffix, "/")
	if suffix == "" || len(seg) == 0 {
		h.serveImportersRoot(w, r)
		return
	}
	impName := seg[0]

	imp, ok := h.imp[impName]
	if !ok {
		http.NotFound(w, r)
		return
	}

	if len(seg) == 1 || seg[1] == "" {
		h.serveImporter(w, r, imp)
		return
	}
	if seg[1] == "callback" {
		h.serveImporterAcctCallback(w, r, imp)
		return
	}
	acctRef, ok := blob.Parse(seg[1])
	if !ok {
		http.NotFound(w, r)
		return
	}
	h.serveImporterAccount(w, r, imp, acctRef)
}
131282
func (h *Hosts) AddHost(host ...Host) {
	h.mux.Lock()
	defer h.mux.Unlock()

	h.hosts = append(h.hosts, host...)
}
511998
func (ipv6 IPv6Addr) Host() IPAddr {
	// Nothing should listen on a broadcast address.
	return IPv6Addr{
		Address: ipv6.Address,
		Mask:    ipv6HostMask,
		Port:    ipv6.Port,
	}
}
585270
func (s *Server) URL(name string, params ...interface{}) string {
	if r := s.routes[name]; r != nil {
		return r.URL(params)
	}
	return ""
}
521395
func (r Route) createURL(host string, params Params) (*url.URL, error) {
	u, err := url.Parse(host)
	if err != nil {
		return nil, err
	}

	path := path.Join(u.Path, r.Path)
	components := strings.Split(path, "/")
	rawComponents := make([]string, len(components))
	copy(rawComponents, components)

	for i, c := range components {
		if len(c) == 0 {
			continue
		}

		val := c
		if c[0] == ':' {
			var ok bool
			val, ok = params[c[1:]]
			if !ok {
				return nil, fmt.Errorf("missing param %s", c)
			}
			components[i] = val
			rawComponents[i] = url.PathEscape(val)
		}
	}

	u.Path = strings.Join(components, "/")
	u.RawPath = strings.Join(rawComponents, "/")

	return u, nil
}
1100199
func rawHost(host string) string {
	u, err := url.Parse(host)
	utils.Check(err)

	if u.IsAbs() {
		return u.Host
	} else {
		return u.Path
	}
}
509636
func (u *DockerRegistryURL) HostPort() string {
	if u.Port == "" {
		return u.Host
	}
	return net.JoinHostPort(u.Host, u.Port)

}