package util import ( "fmt" "net/http" "net/url" ) func MakeURL(r *http.Request, path string, subs ...interface{}) *url.URL { scheme := "https" if r.TLS == nil { scheme = "http" } // Always defer to whatever the proxy told us it was doing because this // could be a mullet-VIP in either direction. if fwProto := r.Header.Get("X-Forwarded-Proto"); fwProto != "" { scheme = fwProto } return &url.URL{ Scheme: scheme, Host: r.Host, Path: fmt.Sprintf(path, subs...), } }