corrections from code review
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
RequestIDString = "request"
|
RequestIDString = "request-id"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func Logger(logger log.Logger) func(http.Handler) http.Handler {
|
|||||||
next.ServeHTTP(wrap, r)
|
next.ServeHTTP(wrap, r)
|
||||||
|
|
||||||
logger.Debug().
|
logger.Debug().
|
||||||
Str("request", r.Header.Get("X-Request-ID")).
|
Str(log.RequestIDString, r.Header.Get("X-Request-ID")).
|
||||||
Str("proto", r.Proto).
|
Str("proto", r.Proto).
|
||||||
Str("method", r.Method).
|
Str("method", r.Method).
|
||||||
Int("status", wrap.Status()).
|
Int("status", wrap.Status()).
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug().Interface("request", updateSpaceRequest).Msg("calling update space on backend")
|
logger.Debug().Interface("payload", updateSpaceRequest).Msg("calling update space on backend")
|
||||||
resp, err := client.UpdateStorageSpace(r.Context(), updateSpaceRequest)
|
resp, err := client.UpdateStorageSpace(r.Context(), updateSpaceRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error().Err(err).Msg("could not update drive: transport error")
|
logger.Error().Err(err).Msg("could not update drive: transport error")
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func AccessLog(logger log.Logger) func(http.Handler) http.Handler {
|
|||||||
|
|
||||||
logger.Info().
|
logger.Info().
|
||||||
Str("proto", r.Proto).
|
Str("proto", r.Proto).
|
||||||
Str("request", chimiddleware.GetReqID(r.Context())).
|
Str(log.RequestIDString, chimiddleware.GetReqID(r.Context())).
|
||||||
Str("remote-addr", r.RemoteAddr).
|
Str("remote-addr", r.RemoteAddr).
|
||||||
Str("method", r.Method).
|
Str("method", r.Method).
|
||||||
Int("status", wrap.Status()).
|
Int("status", wrap.Status()).
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ func (s Thumbnails) GetThumbnail(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
thumbnail, err := s.manager.GetThumbnail(key)
|
thumbnail, err := s.manager.GetThumbnail(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error().
|
logger.Debug().
|
||||||
Err(err).
|
Err(err).
|
||||||
Str("key", key).
|
Str("key", key).
|
||||||
Msg("could not get the thumbnail")
|
Msg("could not get the thumbnail")
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ func (g Webdav) SpacesThumbnail(w http.ResponseWriter, r *http.Request) {
|
|||||||
default:
|
default:
|
||||||
renderError(w, r, errInternalError(err.Error()))
|
renderError(w, r, errInternalError(err.Error()))
|
||||||
}
|
}
|
||||||
logger.Error().Err(err).Msg("could not get thumbnail")
|
logger.Debug().Err(err).Msg("could not get thumbnail")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ func (g Webdav) PublicThumbnailHead(w http.ResponseWriter, r *http.Request) {
|
|||||||
default:
|
default:
|
||||||
renderError(w, r, errInternalError(err.Error()))
|
renderError(w, r, errInternalError(err.Error()))
|
||||||
}
|
}
|
||||||
logger.Error().Err(err).Msg("could not get thumbnail")
|
logger.Debug().Err(err).Msg("could not get thumbnail")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ func (g Webdav) sendThumbnailResponse(rsp *thumbnailssvc.GetThumbnailResponse, w
|
|||||||
dlReq, err := http.NewRequest(http.MethodGet, rsp.DataEndpoint, http.NoBody)
|
dlReq, err := http.NewRequest(http.MethodGet, rsp.DataEndpoint, http.NoBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
renderError(w, r, errInternalError(err.Error()))
|
renderError(w, r, errInternalError(err.Error()))
|
||||||
logger.Error().Err(err).Msg("could not download thumbnail")
|
logger.Error().Err(err).Msg("could not create download thumbnail request")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dlReq.Header.Set("Transfer-Token", rsp.TransferToken)
|
dlReq.Header.Set("Transfer-Token", rsp.TransferToken)
|
||||||
@@ -431,13 +431,13 @@ func (g Webdav) sendThumbnailResponse(rsp *thumbnailssvc.GetThumbnailResponse, w
|
|||||||
dlRsp, err := client.Do(dlReq)
|
dlRsp, err := client.Do(dlReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
renderError(w, r, errInternalError(err.Error()))
|
renderError(w, r, errInternalError(err.Error()))
|
||||||
logger.Error().Err(err).Msg("could not download thumbnail")
|
logger.Error().Err(err).Msg("could not download thumbnail: transport error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer dlRsp.Body.Close()
|
defer dlRsp.Body.Close()
|
||||||
|
|
||||||
if dlRsp.StatusCode != http.StatusOK {
|
if dlRsp.StatusCode != http.StatusOK {
|
||||||
logger.Error().
|
logger.Debug().
|
||||||
Str("transfer_token", rsp.TransferToken).
|
Str("transfer_token", rsp.TransferToken).
|
||||||
Str("data_endpoint", rsp.DataEndpoint).
|
Str("data_endpoint", rsp.DataEndpoint).
|
||||||
Str("response_status", dlRsp.Status).
|
Str("response_status", dlRsp.Status).
|
||||||
|
|||||||
Reference in New Issue
Block a user