Zuletzt aktiv 1 month ago

Änderung 6f3eb2168d1a898bebb5297ec6a98f7137ef6a4d

http-metrics.go Originalformat
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})