Skip to content

Commit

Permalink
move DataIn into handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Jun 28, 2024
1 parent 625269d commit bb844cc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Check failure on line 421 in oauth.go

View workflow job for this annotation

GitHub Actions / build

undefined: logging.CustomResponseWriter
// 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)
}()

Expand Down
3 changes: 0 additions & 3 deletions redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion x509.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Check failure on line 63 in x509.go

View workflow job for this annotation

GitHub Actions / build

undefined: logging.CustomResponseWriter
// 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)
}()

Expand Down

0 comments on commit bb844cc

Please sign in to comment.