func (api *API) Register(r *route.Router) {
	wrap := func(f apiFunc) http.HandlerFunc {
		hf := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			httputil.SetCORS(w, api.CORSOrigin, r)
			result := f(r)
			if result.err != nil {
				api.respondError(w, result.err, result.data)
			} else if result.data != nil {
				api.respond(w, result.data, result.warnings)
			} else {
				w.WriteHeader(http.StatusNoContent)
			}
			if result.finalizer != nil {
				result.finalizer()
			}
		})
		return api.ready(httputil.CompressionHandler{
			Handler: hf,
		}.ServeHTTP)
	}

	r.Options("/*path", wrap(api.options))

	r.Get("/query", wrap(api.query))
	r.Post("/query", wrap(api.query))
	r.Get("/query_range", wrap(api.queryRange))
	r.Post("/query_range", wrap(api.queryRange))

	r.Get("/labels", wrap(api.labelNames))
	r.Post("/labels", wrap(api.labelNames))
	r.Get("/label/:name/values", wrap(api.labelValues))

	r.Get("/series", wrap(api.series))
	r.Post("/series", wrap(api.series))
	r.Del("/series", wrap(api.dropSeries))

	r.Get("/targets", wrap(api.targets))
	r.Get("/targets/metadata", wrap(api.targetMetadata))
	r.Get("/alertmanagers", wrap(api.alertmanagers))

	r.Get("/status/config", wrap(api.serveConfig))
	r.Get("/status/flags", wrap(api.serveFlags))
	r.Post("/read", api.ready(http.HandlerFunc(api.remoteRead)))

	r.Get("/alerts", wrap(api.alerts))
	r.Get("/rules", wrap(api.rules))

	// Admin APIs
	r.Post("/admin/tsdb/delete_series", wrap(api.deleteSeries))
	r.Post("/admin/tsdb/clean_tombstones", wrap(api.cleanTombstones))
	r.Post("/admin/tsdb/snapshot", wrap(api.snapshot))

	r.Put("/admin/tsdb/delete_series", wrap(api.deleteSeries))
	r.Put("/admin/tsdb/clean_tombstones", wrap(api.cleanTombstones))
	r.Put("/admin/tsdb/snapshot", wrap(api.snapshot))

}
func (api *API) Register(r *route.Router) {
	wrap := func(f apiFunc) http.HandlerFunc {
		hf := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			httputil.SetCORS(w, api.CORSOrigin, r)
			result := f(r)
			if result.err != nil {
				api.respondError(w, result.err, result.data)
			} else if result.data != nil {
				api.respond(w, result.data, result.warnings)
			} else {
				w.WriteHeader(http.StatusNoContent)
			}
			if result.finalizer != nil {
				result.finalizer()
			}
		})
		return api.ready(httputil.CompressionHandler{
			Handler: hf,
		}.ServeHTTP)
	}

	r.Options("/*path", wrap(api.options))

	r.Get("/query", wrap(api.query))
	r.Post("/query", wrap(api.query))
	r.Get("/query_range", wrap(api.queryRange))
	r.Post("/query_range", wrap(api.queryRange))

	r.Get("/labels", wrap(api.labelNames))
	r.Post("/labels", wrap(api.labelNames))
	r.Get("/label/:name/values", wrap(api.labelValues))

	r.Get("/series", wrap(api.series))
	r.Post("/series", wrap(api.series))
	r.Del("/series", wrap(api.dropSeries))

	r.Get("/targets", wrap(api.targets))
	r.Get("/targets/metadata", wrap(api.targetMetadata))
	r.Get("/alertmanagers", wrap(api.alertmanagers))

	r.Get("/status/config", wrap(api.serveConfig))
	r.Get("/status/flags", wrap(api.serveFlags))
	r.Post("/read", api.ready(http.HandlerFunc(api.remoteRead)))

	r.Get("/alerts", wrap(api.alerts))
	r.Get("/rules", wrap(api.rules))

	
	r.Post("/admin/tsdb/delete_series", wrap(api.deleteSeries))
	r.Post("/admin/tsdb/clean_tombstones", wrap(api.cleanTombstones))
	r.Post("/admin/tsdb/snapshot", wrap(api.snapshot))

	r.Put("/admin/tsdb/delete_series", wrap(api.deleteSeries))
	r.Put("/admin/tsdb/clean_tombstones", wrap(api.cleanTombstones))
	r.Put("/admin/tsdb/snapshot", wrap(api.snapshot))

}
func ( api * API ) Register ( r * route . Router ) { wrap := func ( f apiFunc ) http . HandlerFunc { hf := http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) { httputil . SetCORS ( w , api . CORSOrigin , r ) result := f ( r ) if result . err != nil { api . respondError ( w , result . err , result . data ) } else if result . data != nil { api . respond ( w , result . data , result . warnings ) } else { w . WriteHeader ( http . StatusNoContent ) } if result . finalizer != nil { result . finalizer ( ) } } ) return api . ready ( httputil . CompressionHandler { Handler : hf , } . ServeHTTP ) } r . Options ( " " , wrap ( api . options ) ) r . Get ( " " , wrap ( api . query ) ) r . Post ( " " , wrap ( api . query ) ) r . Get ( " " , wrap ( api . queryRange ) ) r . Post ( " " , wrap ( api . queryRange ) ) r . Get ( " " , wrap ( api . labelNames ) ) r . Post ( " " , wrap ( api . labelNames ) ) r . Get ( " " , wrap ( api . labelValues ) ) r . Get ( " " , wrap ( api . series ) ) r . Post ( " " , wrap ( api . series ) ) r . Del ( " " , wrap ( api . dropSeries ) ) r . Get ( " " , wrap ( api . targets ) ) r . Get ( " " , wrap ( api . targetMetadata ) ) r . Get ( " " , wrap ( api . alertmanagers ) ) r . Get ( " " , wrap ( api . serveConfig ) ) r . Get ( " " , wrap ( api . serveFlags ) ) r . Post ( " " , api . ready ( http . HandlerFunc ( api . remoteRead ) ) ) r . Get ( " " , wrap ( api . alerts ) ) r . Get ( " " , wrap ( api . rules ) ) // Admin APIs r . Post ( " " , wrap ( api . deleteSeries ) ) r . Post ( " " , wrap ( api . cleanTombstones ) ) r . Post ( " " , wrap ( api . snapshot ) ) r . Put ( " " , wrap ( api . deleteSeries ) ) r . Put ( " " , wrap ( api . cleanTombstones ) ) r . Put ( " " , wrap ( api . snapshot ) ) }
// Register the API's endpoints in the given router.
Register the API s endpoints in the given router .