diff --git a/internal/stats/http.go b/internal/stats/http.go index a6789c65..7415e0db 100644 --- a/internal/stats/http.go +++ b/internal/stats/http.go @@ -72,13 +72,8 @@ func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) { if !ok { // Don't bring the message to the lower case since it's a part of UI // text for the moment. - aghhttp.ErrorAndLog( - ctx, - s.logger, - r, - w, - http.StatusInternalServerError, "Couldn't get statistics data", - ) + const msg = "Couldn't get statistics data" + aghhttp.ErrorAndLog(ctx, s.logger, r, w, http.StatusInternalServerError, msg) return } @@ -162,28 +157,13 @@ func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { reqData := configResp{} err := json.NewDecoder(r.Body).Decode(&reqData) if err != nil { - aghhttp.ErrorAndLog( - ctx, - s.logger, - r, - w, - http.StatusBadRequest, - "json decode: %s", - err, - ) + aghhttp.ErrorAndLog(ctx, s.logger, r, w, http.StatusBadRequest, "json decode: %s", err) return } if !checkInterval(reqData.IntervalDays) { - aghhttp.ErrorAndLog( - ctx, - s.logger, - r, - w, - http.StatusBadRequest, - "Unsupported interval", - ) + aghhttp.ErrorAndLog(ctx, s.logger, r, w, http.StatusBadRequest, "Unsupported interval") return } @@ -206,30 +186,14 @@ func (s *StatsCtx) handlePutStatsConfig(w http.ResponseWriter, r *http.Request) reqData := getConfigResp{} err := json.NewDecoder(r.Body).Decode(&reqData) if err != nil { - aghhttp.ErrorAndLog( - ctx, - s.logger, - r, - w, - http.StatusBadRequest, - "json decode: %s", - err, - ) + aghhttp.ErrorAndLog(ctx, s.logger, r, w, http.StatusBadRequest, "json decode: %s", err) return } engine, err := aghnet.NewIgnoreEngine(reqData.Ignored) if err != nil { - aghhttp.ErrorAndLog( - ctx, - s.logger, - r, - w, - http.StatusUnprocessableEntity, - "ignored: %s", - err, - ) + aghhttp.ErrorAndLog(ctx, s.logger, r, w, http.StatusUnprocessableEntity, "ignored: %s", err) return } @@ -251,14 +215,7 @@ func (s *StatsCtx) handlePutStatsConfig(w http.ResponseWriter, r *http.Request) } if reqData.Enabled == aghalg.NBNull { - aghhttp.ErrorAndLog( - ctx, - s.logger, - r, - w, - http.StatusUnprocessableEntity, - "enabled is null", - ) + aghhttp.ErrorAndLog(ctx, s.logger, r, w, http.StatusUnprocessableEntity, "enabled is null") return }