rest/request.go
func (r *Request) BaseUrl() *url.URL {
	scheme := r.URL.Scheme
	if scheme == "" {
		scheme = "http"
	}

	// HTTP sometimes gives the default scheme as HTTP even when used with TLS
	// Check if TLS is not nil and given back https scheme
	if scheme == "http" && r.TLS != nil {
		scheme = "https"
	}

	host := r.Host
	if len(host) > 0 && host[len(host)-1] == '/' {
		host = host[:len(host)-1]
	}

	return &url.URL{
		Scheme: scheme,
		Host:   host,
	}
}
func (r *Request) BaseUrl() *url.URL {
	scheme := r.URL.Scheme
	if scheme == "" {
		scheme = "http"
	}

	// HTTP sometimes gives the default scheme as HTTP even when used with TLS
	// Check if TLS is not nil and given back https scheme
	if scheme == "http" && r.TLS != nil {
		scheme = "https"
	}

	host := r.Host
	if len(host) > 0 && host[len(host)-1] == '/' {
		host = host[:len(host)-1]
	}

	return &url.URL{
		Scheme: scheme,
		Host:   host,
	}
}
// BaseUrl returns a new URL object with the Host and Scheme taken from the request.
// (without the trailing slash in the host)