oxy
oxy copied to clipboard
response rewrite (headers)
Hi, Thanks for the oxy. I was looking for simple http reverse proxy in go and found this lib.
Is there a way to rewrite or change response header? I'm trying to change response Location Header
In nginx it would be: proxy_redirect redirect replacement
I also needed this, was able to get it to work with a custom fwd RoundTripper:
fwd, _ := forward.New(forward.RoundTripper(&CustomRoundTripper{}))
fwd.ServeHTTP(w, req)
And something like:
type CustomRoundTripper struct{}
func (t *CustomRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
response, err := http.DefaultTransport.RoundTrip(req)
response.Header.Set("Content-Type", "override")
return response, err
}