Propagate Host header from gateway request to the function.

Host HTTP header was not propagated to the function because it is not
a part of http.Request.Header map.

Signed-off-by: Dmitri Rubinstein <dmitri.rubinstein@googlemail.com>
This commit is contained in:
Dmitri Rubinstein
2018-08-14 13:39:48 +02:00
committed by Alex Ellis
parent c86de503c7
commit fd0abe46dd
2 changed files with 37 additions and 0 deletions

View File

@ -53,6 +53,9 @@ func buildUpstreamRequest(r *http.Request, url string) *http.Request {
}
upstreamReq, _ := http.NewRequest(r.Method, url, nil)
if len(r.Host) > 0 {
upstreamReq.Host = r.Host
}
copyHeaders(upstreamReq.Header, &r.Header)
upstreamReq.Header["X-Forwarded-For"] = []string{r.RemoteAddr}