MCPcopy
hub / github.com/prometheus/pushgateway / Register

Method Register

api/v1/api.go:107–122  ·  view source on GitHub ↗

Register registers the API handlers under their correct routes in the given router.

(r *route.Router)

Source from the content-addressed store, hash-verified

105// Register registers the API handlers under their correct routes
106// in the given router.
107func (api *API) Register(r *route.Router) {
108 wrap := func(handlerName string, f http.HandlerFunc) http.HandlerFunc {
109 return handler.InstrumentWithCounter(
110 handlerName,
111 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
112 setCORS(w)
113 f(w, r)
114 }),
115 )
116 }
117
118 r.Options("/*path", wrap("api/v1/options", func(w http.ResponseWriter, r *http.Request) {}))
119
120 r.Get("/status", wrap("api/v1/status", api.status))
121 r.Get("/metrics", wrap("api/v1/metrics", api.metrics))
122}
123
124type metrics struct {
125 Timestamp time.Time `json:"time_stamp"`

Callers 1

mainFunction · 0.80

Calls 2

InstrumentWithCounterFunction · 0.92
setCORSFunction · 0.85

Tested by

no test coverage detected