Register registers the API handlers under their correct routes in the given router.
(r *route.Router)
| 105 | // Register registers the API handlers under their correct routes |
| 106 | // in the given router. |
| 107 | func (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 | |
| 124 | type metrics struct { |
| 125 | Timestamp time.Time `json:"time_stamp"` |
no test coverage detected