mc-router/server/api_server.go

26 lines
534 B
Go
Raw Normal View History

2018-05-08 05:16:01 +02:00
package server
import (
"expvar"
"net/http"
2018-05-08 05:16:01 +02:00
"github.com/gorilla/mux"
2024-11-09 19:43:51 +01:00
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sirupsen/logrus"
2018-05-08 05:16:01 +02:00
)
var apiRoutes = mux.NewRouter()
func StartApiServer(apiBinding string) {
logrus.WithField("binding", apiBinding).Info("Serving API requests")
apiRoutes.Path("/vars").Handler(expvar.Handler())
2024-11-09 19:43:51 +01:00
apiRoutes.Path("/metrics").Handler(promhttp.Handler())
2018-05-08 05:16:01 +02:00
go func() {
logrus.WithError(
http.ListenAndServe(apiBinding, apiRoutes)).Error("API server failed")
}()
}