MCPcopy Create free account
hub / github.com/felixge/httpsnoop / CaptureMetricsFn

Function CaptureMetricsFn

capture_metrics.go:37–41  ·  view source on GitHub ↗

CaptureMetricsFn wraps w and calls fn with the wrapped w and returns the resulting metrics. This is very similar to CaptureMetrics (which is just sugar on top of this func), but is a more usable interface if your application doesn't use the Go http.Handler interface.

(w http.ResponseWriter, fn func(http.ResponseWriter))

Source from the content-addressed store, hash-verified

35// sugar on top of this func), but is a more usable interface if your
36// application doesn't use the Go http.Handler interface.
37func CaptureMetricsFn(w http.ResponseWriter, fn func(http.ResponseWriter)) Metrics {
38 m := Metrics{Code: http.StatusOK}
39 m.CaptureMetrics(w, fn)
40 return m
41}
42
43// CaptureMetrics wraps w and calls fn with the wrapped w and updates
44// Metrics m with the resulting metrics. This is similar to CaptureMetricsFn,

Callers 1

CaptureMetricsFunction · 0.85

Calls 1

CaptureMetricsMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…