oxy icon indicating copy to clipboard operation
oxy copied to clipboard

response rewrite (headers)

Open kernel164 opened this issue 10 years ago • 1 comments

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

kernel164 avatar Mar 11 '16 06:03 kernel164

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
}

fotinakis avatar Nov 29 '16 21:11 fotinakis