Skip to content

Commit

Permalink
all: imp code
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Sep 4, 2024
1 parent 363a16f commit bb3c0c8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
4 changes: 1 addition & 3 deletions internal/aghhttp/aghhttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,15 @@ 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,
format string,
args ...any,
) {
text := fmt.Sprintf(format, args...)
l.Log(
l.ErrorContext(
ctx,
lvl,
"http error",
"method", r.Method,
"host", r.Host,
Expand Down
9 changes: 0 additions & 9 deletions internal/stats/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package stats

import (
"encoding/json"
"log/slog"
"net/http"
"time"

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit bb3c0c8

Please sign in to comment.