Skip to content

Commit

Permalink
rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 committed Jul 10, 2024
1 parent 16929ff commit 736cf3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions internal/util/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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{
Expand Down

0 comments on commit 736cf3c

Please sign in to comment.