Skip to content

Commit

Permalink
fix(homepage): Use metrics-path specified in configuration instead of…
Browse files Browse the repository at this point in the history
… hardcoded
  • Loading branch information
vmercierfr committed Nov 1, 2023
1 parent e174d56 commit b790bc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions internal/infra/http/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"github.com/qonto/prometheus-rds-exporter/internal/infra/build"
)

type homeHandler struct{}
type homeHandler struct {
metricPath string
}

func (h homeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, `<html>
Expand All @@ -16,7 +18,7 @@ func (h homeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
</head>
<body>
<h1>Prometheus RDS Exporter (%s)</h1>
<p><a href='/metrics'>Metrics</a></p>
<p><a href='%s'>Metrics</a></p>
</body>
</html>`, build.Version)
</html>`, build.Version, h.metricPath)
}
2 changes: 1 addition & 1 deletion internal/infra/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *Component) Start() error {
BaseContext: func(_ net.Listener) context.Context { return ctx },
}

http.Handle("/", homeHandler{})
http.Handle("/", homeHandler{metricPath: c.config.metricPath})
http.Handle(c.config.metricPath, promhttp.Handler())

signalChan := make(chan os.Signal, 1)
Expand Down

0 comments on commit b790bc7

Please sign in to comment.