[hw-1] implement cart service

This commit is contained in:
Никита Шубин
2025-05-25 15:49:17 +00:00
parent 3d3f10647b
commit 5077f04b0c
28 changed files with 1151 additions and 2 deletions

View File

@@ -0,0 +1,26 @@
package middlewares
import (
"net/http"
"time"
"github.com/rs/zerolog/log"
)
type TimerMiddleware struct {
h http.Handler
}
func NewTimerMiddleware(h http.Handler) http.Handler {
return &TimerMiddleware{
h: h,
}
}
func (m *TimerMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer func(now time.Time) {
log.Debug().Msgf("%s %s spent %s", r.Method, r.URL.String(), time.Since(now))
}(time.Now())
m.h.ServeHTTP(w, r)
}