Skip to content

Instantly share code, notes, and snippets.

@sidneyw
Created August 6, 2019 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidneyw/e37942e4620ad2cbd8d2c6bcebd20968 to your computer and use it in GitHub Desktop.
Save sidneyw/e37942e4620ad2cbd8d2c6bcebd20968 to your computer and use it in GitHub Desktop.
proxy := httputil.NewSingleHostReverseProxy(u)
// Configure proxy.Director ...
// ModifyResponse runs before forwarding the downstream response back to the client
proxy.ModifyResponse = func(res *http.Response) error {
responseContent := map[string]interface{}{}
err := parseResponse(res, &responseContent)
if err != nil {
return err
}
return captureMetrics(responseContent)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment