// Register the API's endpoints in the given router. func (api *API) Register(r *route.Router) { if api.context == nil { api.context = route.Context } instr := func(name string, f apiFunc) http.HandlerFunc { return prometheus.InstrumentHandlerFunc(name, func(w http.ResponseWriter, r *http.Request) { setCORS(w) if data, err := f(r); err != nil { respondError(w, err, data) } else { respond(w, data) } }) } r.Get("/query", instr("query", api.query)) r.Get("/query_range", instr("query_range", api.queryRange)) r.Get("/label/:name/values", instr("label_values", api.labelValues)) r.Get("/series", instr("series", api.series)) r.Del("/series", instr("drop_series", api.dropSeries)) }
// RegisterHandler registers the handler for the various endpoints below /api. func (api *API) Register(router *route.Router) { router.Get("/query", handle("query", api.Query)) router.Get("/query_range", handle("query_range", api.QueryRange)) router.Get("/metrics", handle("metrics", api.Metrics)) }