on main help sign in
fix: handle nil body in http log
7f77496Kujtim Hoxha
internal/log/http.go+3
@@ -79,6 +79,9 @@ func (h *HTTPRoundTripLogger) RoundTrip(req *http.Request) (*http.Response, erro
79}
79}
80
80
81func bodyToString(body io.ReadCloser) string {
81func bodyToString(body io.ReadCloser) string {
82+ if body == nil {
83+ return ""
84+ }
82 src, err := io.ReadAll(body)
85 src, err := io.ReadAll(body)
83 if err != nil {
86 if err != nil {
84 slog.Error("Failed to read body", "error", err)
87 slog.Error("Failed to read body", "error", err)