-func (srv *Server) setup() {
- if srv.Cluster.ManagementToken == "" {
- srv.httpHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- http.Error(w, "Management API authentication is not configured", http.StatusForbidden)
- })
- } else {
- mux := httprouter.New()
- metricsH := promhttp.HandlerFor(srv.Metrics.reg, promhttp.HandlerOpts{
- ErrorLog: srv.Logger,
- })
- mux.Handler("GET", "/metrics", metricsH)
- mux.Handler("GET", "/metrics.json", metricsH)
- srv.httpHandler = auth.RequireLiteralToken(srv.Cluster.ManagementToken, mux)
- }