mc-router/server/api_server.go

22 lines
417 B
Go
Raw Normal View History

2018-05-08 05:16:01 +02:00
package server
import (
"expvar"
2018-05-08 05:16:01 +02:00
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
"net/http"
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")
}()
}