Files
mc-router/server/api_server.go
T
Geoff Bourne 172aed3893 Revert code cleanup for now (#428)
* Revert "Code cleanup in and around connector (#427)"

This reverts commit b3e88db48c.

* Revert "Refactored server setup and run out of main (#425)"

This reverts commit 05c57c3b85.

* Revert "Code cleanup of routes config loader and API server (#424)"

This reverts commit 1ee3eb4de3.
2025-07-06 20:16:26 -05:00

26 lines
534 B
Go

package server
import (
"expvar"
"net/http"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sirupsen/logrus"
)
var apiRoutes = mux.NewRouter()
func StartApiServer(apiBinding string) {
logrus.WithField("binding", apiBinding).Info("Serving API requests")
apiRoutes.Path("/vars").Handler(expvar.Handler())
apiRoutes.Path("/metrics").Handler(promhttp.Handler())
go func() {
logrus.WithError(
http.ListenAndServe(apiBinding, apiRoutes)).Error("API server failed")
}()
}