all: imp code

This commit is contained in:
Stanislav Chzhen 2024-09-04 19:10:36 +03:00
parent 363a16f6bb
commit bb3c0c8002
2 changed files with 1 additions and 12 deletions

View File

@ -47,7 +47,6 @@ func Error(r *http.Request, w http.ResponseWriter, code int, format string, args
func ErrorAndLog(
ctx context.Context,
l *slog.Logger,
lvl slog.Level,
r *http.Request,
w http.ResponseWriter,
code int,
@ -55,9 +54,8 @@ func ErrorAndLog(
args ...any,
) {
text := fmt.Sprintf(format, args...)
l.Log(
l.ErrorContext(
ctx,
lvl,
"http error",
"method", r.Method,
"host", r.Host,

View File

@ -4,7 +4,6 @@ package stats
import (
"encoding/json"
"log/slog"
"net/http"
"time"
@ -76,7 +75,6 @@ func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) {
aghhttp.ErrorAndLog(
ctx,
s.logger,
slog.LevelError,
r,
w,
http.StatusInternalServerError, "Couldn't get statistics data",
@ -167,7 +165,6 @@ func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
aghhttp.ErrorAndLog(
ctx,
s.logger,
slog.LevelError,
r,
w,
http.StatusBadRequest,
@ -182,7 +179,6 @@ func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
aghhttp.ErrorAndLog(
ctx,
s.logger,
slog.LevelError,
r,
w,
http.StatusBadRequest,
@ -213,7 +209,6 @@ func (s *StatsCtx) handlePutStatsConfig(w http.ResponseWriter, r *http.Request)
aghhttp.ErrorAndLog(
ctx,
s.logger,
slog.LevelError,
r,
w,
http.StatusBadRequest,
@ -229,7 +224,6 @@ func (s *StatsCtx) handlePutStatsConfig(w http.ResponseWriter, r *http.Request)
aghhttp.ErrorAndLog(
ctx,
s.logger,
slog.LevelError,
r,
w,
http.StatusUnprocessableEntity,
@ -246,7 +240,6 @@ func (s *StatsCtx) handlePutStatsConfig(w http.ResponseWriter, r *http.Request)
aghhttp.ErrorAndLog(
ctx,
s.logger,
slog.LevelError,
r,
w,
http.StatusUnprocessableEntity,
@ -261,7 +254,6 @@ func (s *StatsCtx) handlePutStatsConfig(w http.ResponseWriter, r *http.Request)
aghhttp.ErrorAndLog(
ctx,
s.logger,
slog.LevelError,
r,
w,
http.StatusUnprocessableEntity,
@ -288,7 +280,6 @@ func (s *StatsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) {
aghhttp.ErrorAndLog(
r.Context(),
s.logger,
slog.LevelError,
r,
w,
http.StatusInternalServerError,