mila / http handler metrics wrapper
0 лайк(-ов)
0 форк(-ов)
1 файл(-ов)
Последняя активность 4 weeks ago
| 1 | import "github.com/felixge/httpsnoop" |
| 2 | |
| 3 | handler := http.StripPrefix("/path/", http.FileServer(http.Dir("/tmp/files/"))) |
| 4 | |
| 5 | wrappedHandler := 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 | }) |
Новее
Позже