Files
Alessandro Cabbia accf15410c refactor: separating http handlers from routing setup (#350)
* fix: offload prometheus logic to the monitoring package

* fix: offload ui logic to the asset package

* refactor: use handlers coming from assets and monitoring package

* ci: add unit test run and vet command

* fix: make vet happy and adjust code
2023-10-14 11:19:58 -07:00

29 lines
482 B
Go

package monitoring
import (
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/zerolog"
)
type API struct {
logger zerolog.Logger
}
func (a *API) RegisterEndpoints(router *http.ServeMux) {
router.HandleFunc("/metrics", a.prometheusHTTP)
}
func (a *API) prometheusHTTP(w http.ResponseWriter, r *http.Request) {
promhttp.Handler().ServeHTTP(w, r)
}
func NewAPI(logger zerolog.Logger) *API {
a := new(API)
a.logger = logger
return a
}