diff --git a/oauth.go b/oauth.go index fc3af54..f327135 100644 --- a/oauth.go +++ b/oauth.go @@ -419,8 +419,9 @@ func oauthRequestHandler(w http.ResponseWriter, r *http.Request) { // Use the custom response writer to capture number of bytes written back by BE crw := &logging.CustomResponseWriter{ResponseWriter: w} - // collect DataOut once we process our request + // collect how much bytes we consume and write out with every HTTP request defer func() { + DataIn += float64(r.ContentLength) DataOut += float64(crw.BytesWritten) }() diff --git a/redirect.go b/redirect.go index a16befb..29f8896 100644 --- a/redirect.go +++ b/redirect.go @@ -143,9 +143,6 @@ func reverseProxy(targetURL string, w http.ResponseWriter, r *http.Request) { rw.Write([]byte(err.Error())) } - // collect how much bytes each HTTP request has - DataIn += float64(r.ContentLength) - // ServeHttp is non blocking and uses a go routine under the hood proxy.ServeHTTP(w, r) } diff --git a/x509.go b/x509.go index 5dac63f..049e1c3 100644 --- a/x509.go +++ b/x509.go @@ -61,8 +61,9 @@ func x509RequestHandler(w http.ResponseWriter, r *http.Request) { // Use the custom response writer to capture number of bytes written back by BE crw := &logging.CustomResponseWriter{ResponseWriter: w} - // collect DataOut once we process our request + // collect how much bytes we consume and write out with every HTTP request defer func() { + DataIn += float64(r.ContentLength) DataOut += float64(crw.BytesWritten) }()