Show metrics icon in sidebar if prometheus-addr is specified

This commit is contained in:
Ken Hibino
2021-11-25 07:50:12 -08:00
parent e8775539ae
commit c9fcd9c7ae
7 changed files with 34 additions and 13 deletions

View File

@@ -15,10 +15,11 @@ import (
// the path to the index file within that static directory are used to
// serve the SPA.
type uiAssetsHandler struct {
rootPath string
contents embed.FS
staticDirPath string
indexFileName string
rootPath string
contents embed.FS
staticDirPath string
indexFileName string
prometheusAddr string
}
// ServeHTTP inspects the URL path to locate a file within the static dir
@@ -59,9 +60,11 @@ func (h *uiAssetsHandler) renderIndexFile(w http.ResponseWriter) error {
return err
}
data := struct {
RootPath string
RootPath string
PrometheusAddr string
}{
RootPath: h.rootPath,
RootPath: h.rootPath,
PrometheusAddr: h.prometheusAddr,
}
return tmpl.Execute(w, data)
}