func proxyAsync(engine *cluster.Engine, w http.ResponseWriter, r *http.Request, callback func(*http.Response)) error { // RequestURI may not be sent to client r.RequestURI = "" client, scheme := engine.HTTPClientAndScheme() r.URL.Scheme = scheme r.URL.Host = engine.Addr log.WithFields(log.Fields{"method": r.Method, "url": r.URL}).Debug("Proxy request") resp, err := client.Do(r) if err != nil { return err } copyHeader(w.Header(), resp.Header) w.WriteHeader(resp.StatusCode) io.Copy(NewWriteFlusher(w), resp.Body) if callback != nil { callback(resp) } // cleanup resp.Body.Close() return nil }