diff options
Diffstat (limited to 'internal/metrics/metrics.go')
| -rw-r--r-- | internal/metrics/metrics.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index 9030d67..9030775 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | package metrics | 1 | package metrics |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | _ "embed" | ||
| 4 | "net/http" | 5 | "net/http" |
| 5 | 6 | ||
| 6 | "github.com/prometheus/client_golang/prometheus" | 7 | "github.com/prometheus/client_golang/prometheus" |
| @@ -284,8 +285,15 @@ const ( | |||
| 284 | StatusInvalidRequest RequestStatus = "invalid_request" | 285 | StatusInvalidRequest RequestStatus = "invalid_request" |
| 285 | ) | 286 | ) |
| 286 | 287 | ||
| 288 | //go:embed dashboard.html | ||
| 289 | var dashboardHTML []byte | ||
| 290 | |||
| 287 | func (m *Metrics) Serve(addr, path string) error { | 291 | func (m *Metrics) Serve(addr, path string) error { |
| 288 | mux := http.NewServeMux() | 292 | mux := http.NewServeMux() |
| 289 | mux.Handle(path, promhttp.Handler()) | 293 | mux.Handle(path, promhttp.Handler()) |
| 294 | mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
| 295 | w.Header().Set("Content-Type", "text/html; charset=utf-8") | ||
| 296 | w.Write(dashboardHTML) | ||
| 297 | }) | ||
| 290 | return http.ListenAndServe(addr, mux) | 298 | return http.ListenAndServe(addr, mux) |
| 291 | } | 299 | } |
