mc-router/server/api_server.go

23 lines
418 B
Go
Raw Permalink 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"
"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())
2018-05-08 05:16:01 +02:00
go func() {
logrus.WithError(
http.ListenAndServe(apiBinding, apiRoutes)).Error("API server failed")
}()
}