2018-05-08 05:16:01 +02:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2019-07-14 23:34:46 +02:00
|
|
|
"expvar"
|
2021-12-12 01:20:19 +01:00
|
|
|
"net/http"
|
|
|
|
|
2018-05-08 05:16:01 +02:00
|
|
|
"github.com/gorilla/mux"
|
2019-07-14 23:34:46 +02:00
|
|
|
"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")
|
2019-07-14 23:34:46 +02:00
|
|
|
|
|
|
|
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")
|
|
|
|
}()
|
|
|
|
}
|