blob: 31cd94d961d1d5ec4ab2671a18d671fb6277b4ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
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...),
}
}
|