Add request and response modifier support

This commit is contained in:
David Stotijn
2019-11-24 19:46:38 +01:00
parent ee8e4330c1
commit 9d9c46c63f
3 changed files with 62 additions and 18 deletions

View File

@ -33,6 +33,15 @@ func main() {
log.Fatalf("[FATAL] Could not create Proxy: %v", err)
}
proxy.UseRequestModifier(func(req *http.Request) {
log.Printf("[DEBUG] Incoming request: %v", req.URL)
})
proxy.UseResponseModifier(func(res *http.Response) error {
log.Printf("[DEBUG] Downstream response: %v %v %v", res.Proto, res.StatusCode, http.StatusText(res.StatusCode))
return nil
})
s := &http.Server{
Addr: ":8080",
Handler: proxy,