Commit 6f46dbe
Changed files (1)
pkg
prxy
pkg/prxy/prxy.go
@@ -18,17 +18,16 @@ func New(routes map[string]string) http.Handler {
}
return &httputil.ReverseProxy{
- Director: func(r *http.Request) {
- host, _, err := net.SplitHostPort(r.Host)
+ Rewrite: func(r *httputil.ProxyRequest) {
+ host, _, err := net.SplitHostPort(r.In.Host)
if err != nil {
- fmt.Printf("%v\n", err)
+ log.Println(err)
return
}
destination := mapped[host]
- r.URL.Scheme = destination.Scheme
- r.Host = destination.Host
- r.URL.Host = destination.Host
+ r.SetXForwarded()
+ r.SetURL(destination)
},
Transport: http.DefaultTransport,
FlushInterval: -1,