code: func BaseURL(urlStr string, req *http.Request) (string, error) {
  	var baseURL string
  	defaultURL, err := url.Parse(urlStr)
  	if err != nil {
  		return baseURL, err
  	}
  	prefix := path.Clean(defaultURL.Path)
  	scheme := "http"
  	if req.TLS != nil {
  		scheme = "https"
  	}
  	host := req.Host
  	if defaultURL.Host != "" {
  		host = defaultURL.Host
  	}
  	if defaultURL.Scheme != "" {
  		scheme = defaultURL.Scheme
  	}
  	baseURL = scheme + "://" + host + prefix
  	return baseURL, nil
  }
docs: // BaseURL returns the base URL (scheme + host and optional port +
  // blobserver prefix) that should be used for requests (and responses)
  // subsequent to req. The returned URL does not end in a trailing slash.
  // The scheme and host:port are taken from urlStr if present,
  // or derived from req otherwise.
  // The prefix part comes from urlStr.