Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

response rewrite (headers) #35

Open
kernel164 opened this issue Mar 11, 2016 · 1 comment
Open

response rewrite (headers) #35

kernel164 opened this issue Mar 11, 2016 · 1 comment
Labels

Comments

@kernel164
Copy link

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

@fotinakis
Copy link
Contributor

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
}

@ldez ldez added the question label Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants