MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / WithMonitoring

Method WithMonitoring

server/middlewares.go:16–30  ·  view source on GitHub ↗

WithMonitoring wraps RouteHandler with monitoring handling.

(h RouteHandler)

Source from the content-addressed store, hash-verified

14
15// WithMonitoring wraps RouteHandler with monitoring handling.
16func (r *Router) WithMonitoring(h RouteHandler) RouteHandler {
17 if !r.monitoring.Enabled() {
18 return h
19 }
20
21 return func(reqID string, rw ResponseWriter, req *http.Request) *Error {
22 ctx, cancel, newRw := r.monitoring.StartRequest(req.Context(), rw.HTTPResponseWriter(), req)
23 defer cancel()
24
25 // Replace rw.ResponseWriter with new one returned from monitoring
26 rw.SetHTTPResponseWriter(newRw)
27
28 return h(reqID, rw, req.WithContext(ctx))
29 }
30}
31
32// WithCORS wraps RouteHandler with CORS handling
33func (r *Router) WithCORS(h RouteHandler) RouteHandler {

Callers

nothing calls this directly

Calls 4

HTTPResponseWriterMethod · 0.80
SetHTTPResponseWriterMethod · 0.80
EnabledMethod · 0.65
StartRequestMethod · 0.65

Tested by

no test coverage detected