httplog
httplog copied to clipboard
Logging compressed response
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
:
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"