How do I get the absolute URL, including scheme and host in
func (plugin *MyPlugin) ServeHTTP(response http.ResponseWriter, request *http.Request)
I can see request.URL
or request.RequestURI
but these have only the path and not the host.
I can get the host from request.Host
but there is no scheme.
request.URL.Scheme
is empty, which makes sense as request.URL
is only a path.
So how do I get my full URL?
Do those headers exist?
X-Forwarded-For: 5.6.7.8
X-Forwarded-Host: sub1.example.com
X-Forwarded-Port: 443
X-Forwarded-Proto: https
X-Forwarded-Server: s1
X-Real-Ip: 5.6.7.8
Yes X-Forwarded-Proto
does. I’d actually just found it and implemented a get on it and then defaulted to https. It’s a bit of a muddle mess pulling bits from here there and everywhere to make the URL which I’d suggest should be full in Request.URL but it’s working now. Thanks very much for your reply.