3
0
corteza/pkg/api/server/metrics.go
Denis Arh 1d59a3acf2 Allow custom URL prefix for all corteza endpoints
Add new env. variables and options
 - HTTP_BASE_URL to control URL prefix, defaults to /
 - HTTP_SSL_TERMINATED to explicitly set if Corteza is running behind HTTPS
Refresh and document webapp/Makefile with more dev tasks
Fix all absolute URLs in applications, logos, icons
Improve logic behind integrated webapp serving, inject/replace <base href> tag according to URL prefix
Prevent mounting api & webapps to the same base
2021-05-09 16:47:19 +02:00

25 lines
620 B
Go

package server
import (
"github.com/99designs/basicauth-go"
"net/http"
"github.com/766b/chi-prometheus"
"github.com/go-chi/chi"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
// MetricsMiddleware is the request logger that provides metrics to prometheus
func metricsMiddleware(name string) func(http.Handler) http.Handler {
return chiprometheus.NewMiddleware(name)
}
func metricsMount(r chi.Router, username, password string) {
r.Route("/metrics", func(r chi.Router) {
r.Use(basicauth.New("Metrics", map[string][]string{
username: {password},
}))
r.Handle("/", promhttp.Handler())
})
}