ЛР 4: вложения в S3 и двусторонняя сверка хранилищ

This commit is contained in:
2026-11-15 11:50:57 +03:00
parent ec540a1a72
commit b58e703546
160 changed files with 16598 additions and 25 deletions
@@ -0,0 +1,39 @@
package middleware
import (
"log/slog"
"net/http"
"time"
)
type responseWriter struct {
http.ResponseWriter
status int
}
func (w *responseWriter) WriteHeader(status int) {
w.status = status
w.ResponseWriter.WriteHeader(status)
}
func (m *Middleware) Logging(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
rw := &responseWriter{
ResponseWriter: w,
status: http.StatusOK,
}
next.ServeHTTP(rw, r)
slog.Info(
"http request",
"method", r.Method,
"path", r.URL.Path,
"status", rw.status,
"duration", time.Since(start),
"request_id", RequestIDFromContext(r.Context()),
)
})
}