mirror of
https://github.com/itzg/mc-router.git
synced 2024-11-27 12:26:01 +01:00
23 lines
418 B
Go
23 lines
418 B
Go
package server
|
|
|
|
import (
|
|
"expvar"
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
"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())
|
|
|
|
go func() {
|
|
logrus.WithError(
|
|
http.ListenAndServe(apiBinding, apiRoutes)).Error("API server failed")
|
|
}()
|
|
}
|