From 377c219fd9dd450b60bd4ed487daa1ee4884abd8 Mon Sep 17 00:00:00 2001 From: Sylvain Rabot Date: Tue, 7 Jan 2020 20:00:05 +0100 Subject: [PATCH] Rename the non-exposed field "count" to "size" --- pkg/middlewares/accesslog/capture_request_reader.go | 4 +++- pkg/middlewares/accesslog/logdata.go | 3 ++- pkg/middlewares/accesslog/logger.go | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/middlewares/accesslog/capture_request_reader.go b/pkg/middlewares/accesslog/capture_request_reader.go index 4fd0088b1..7ff090667 100644 --- a/pkg/middlewares/accesslog/capture_request_reader.go +++ b/pkg/middlewares/accesslog/capture_request_reader.go @@ -3,8 +3,10 @@ package accesslog import "io" type captureRequestReader struct { + // source ReadCloser from where the request body is read. source io.ReadCloser - count int64 + // count Counts the number of bytes read (when captureRequestReader.Read is called). + count int64 } func (r *captureRequestReader) Read(p []byte) (int, error) { diff --git a/pkg/middlewares/accesslog/logdata.go b/pkg/middlewares/accesslog/logdata.go index ae39ce9d6..a9e3f2906 100644 --- a/pkg/middlewares/accesslog/logdata.go +++ b/pkg/middlewares/accesslog/logdata.go @@ -129,5 +129,6 @@ type downstreamResponse struct { type request struct { headers http.Header - count int64 + // Request body size + size int64 } diff --git a/pkg/middlewares/accesslog/logger.go b/pkg/middlewares/accesslog/logger.go index 8114d9319..f6e0e4920 100644 --- a/pkg/middlewares/accesslog/logger.go +++ b/pkg/middlewares/accesslog/logger.go @@ -214,7 +214,7 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request, next http size: crw.Size(), } if crr != nil { - logDataTable.Request.count = crr.count + logDataTable.Request.size = crr.count } if h.config.BufferingSize > 0 { @@ -280,7 +280,7 @@ func (h *Handler) logTheRoundTrip(logDataTable *LogData) { retryAttempts = 0 } core[RetryAttempts] = retryAttempts - core[RequestContentSize] = logDataTable.Request.count + core[RequestContentSize] = logDataTable.Request.size status := logDataTable.DownstreamResponse.status core[DownstreamStatus] = status