mirror of
https://github.com/itzg/mc-router.git
synced 2024-12-22 16:17:38 +01:00
22 lines
417 B
Go
22 lines
417 B
Go
package server
|
|
|
|
import (
|
|
"expvar"
|
|
"github.com/gorilla/mux"
|
|
"github.com/sirupsen/logrus"
|
|
"net/http"
|
|
)
|
|
|
|
var apiRoutes = mux.NewRouter()
|
|
|
|
func StartApiServer(apiBinding string) {
|
|
logrus.WithField("binding", apiBinding).Info("Serving API requests")
|
|
|
|
apiRoutes.Path("/vars").Handler(expvar.Handler())
|
|
|
|
go func() {
|
|
logrus.WithError(
|
|
http.ListenAndServe(apiBinding, apiRoutes)).Error("API server failed")
|
|
}()
|
|
}
|