Dernière activité 1 month ago

http-metrics.go Brut
1import "github.com/felixge/httpsnoop"
2
3handler := http.StripPrefix("/path/", http.FileServer(http.Dir("/tmp/files/")))
4
5wrappedHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
6 metrics := httpsnoop.CaptureMetrics(handler, w, r)
7 slog.Info(fmt.Sprintf("%v %v", r.Method, r.URL), "code", metrics.Code)
8})