add log to http utils.

This commit is contained in:
Miroslav Šedivý 2020-11-14 18:27:20 +01:00
parent 4a5654f2ef
commit 8a9f465d0b

View File

@ -4,6 +4,8 @@ import (
"fmt"
"net/http"
"encoding/json"
"github.com/rs/zerolog/log"
)
type ErrResponse struct {
@ -24,8 +26,9 @@ func HttpJsonResponse(w http.ResponseWriter, status int, res interface{}) {
w.WriteHeader(status)
if err := json.NewEncoder(w).Encode(res); err != nil {
// TODO: Log.
//log.Warn().Err(err).Msg("failed writing json error response")
log.Warn().Err(err).
Str("module", "http").
Msg("failed writing json error response")
}
}