add log to http utils.
This commit is contained in:
parent
4a5654f2ef
commit
8a9f465d0b
1 changed files with 5 additions and 2 deletions
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrResponse struct {
|
type ErrResponse struct {
|
||||||
|
|
@ -24,8 +26,9 @@ func HttpJsonResponse(w http.ResponseWriter, status int, res interface{}) {
|
||||||
w.WriteHeader(status)
|
w.WriteHeader(status)
|
||||||
|
|
||||||
if err := json.NewEncoder(w).Encode(res); err != nil {
|
if err := json.NewEncoder(w).Encode(res); err != nil {
|
||||||
// TODO: Log.
|
log.Warn().Err(err).
|
||||||
//log.Warn().Err(err).Msg("failed writing json error response")
|
Str("module", "http").
|
||||||
|
Msg("failed writing json error response")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue