From 736cf3ceca2834b434445c6d8a5ac002fb22c311 Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Wed, 3 Jul 2024 12:23:52 -0400 Subject: [PATCH] rename variables --- internal/middleware/middleware.go | 4 ++-- internal/util/reader.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/middleware/middleware.go b/internal/middleware/middleware.go index 1a5ee4e9..5ab89392 100644 --- a/internal/middleware/middleware.go +++ b/internal/middleware/middleware.go @@ -218,11 +218,11 @@ func base64urlDecode(base64String string) ([]byte, error) { return idStr, nil } -func GzipMiddleware(maxInputPayloadSize ct.OptBase2Bytes) mux.MiddlewareFunc { +func GzipMiddleware(maxInboundPayloadSize ct.OptBase2Bytes) mux.MiddlewareFunc { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { isGzipped := strings.Contains(r.Header.Get("Content-Encoding"), "gzip") - reader, err := util.NewReader(r.Body, isGzipped, maxInputPayloadSize) + reader, err := util.NewReader(r.Body, isGzipped, maxInboundPayloadSize) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return diff --git a/internal/util/reader.go b/internal/util/reader.go index 67f8214a..a80d6fdc 100644 --- a/internal/util/reader.go +++ b/internal/util/reader.go @@ -25,10 +25,10 @@ type PayloadReader struct { } // NewReader creates a new reader -func NewReader(r io.ReadCloser, isGzipped bool, maxInputPayloadSize ct.OptBase2Bytes) (io.ReadCloser, error) { +func NewReader(r io.ReadCloser, isGzipped bool, maxInboundPayloadSize ct.OptBase2Bytes) (io.ReadCloser, error) { // If this isn't compressed, and we don't want to limit the size, just // return the original reader - if !isGzipped && !maxInputPayloadSize.IsDefined() { + if !isGzipped && !maxInboundPayloadSize.IsDefined() { return r, nil } @@ -46,14 +46,14 @@ func NewReader(r io.ReadCloser, isGzipped bool, maxInputPayloadSize ct.OptBase2B } // If we don't want to limit the size, just return the gzip reader - if !maxInputPayloadSize.IsDefined() { + if !maxInboundPayloadSize.IsDefined() { return gzipReader, nil } s = gzipReader } - maxBytes := int64(maxInputPayloadSize.GetOrElse(0)) + maxBytes := int64(maxInboundPayloadSize.GetOrElse(0)) stream := io.LimitReader(s, maxBytes).(*io.LimitedReader) payloadReader := &PayloadReader{