Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging compressed response #22

Open
benja8151 opened this issue Apr 20, 2023 · 0 comments
Open

Logging compressed response #22

benja8151 opened this issue Apr 20, 2023 · 0 comments

Comments

@benja8151
Copy link

benja8151 commented Apr 20, 2023

Using httplog in combination with chi compress middleware logs compressed response body. Has anyone encountered similar issues before? I wrote a custom implementation of httplog where I manually decompress response, but I'm wondering if there is a cleaner solution?

To reproduce, add compress middleware to example and set Content-Type header to text/plain:

// main.go, 24-27
r.Use(httplog.RequestLogger(logger, []string{"/ping"}))
r.Use(middleware.Compress(5))
r.Use(middleware.SetHeader("Content-Type", "text/plain"))
r.Use(middleware.Heartbeat("/ping"))

Example of console output when calling /warn endpoint with JSON: false and Concise: false:
image
where you can see response body logged as "\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000�*O,�S�H-J\u0005\u0004\u0000\u0000��?�\u001dv\t\u0000\u0000\u0000"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant