From 3380692f7119d31cce3408ca6828277b5179063c Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Mon, 23 Mar 2015 19:39:31 +0100 Subject: [PATCH] Only serve alerts page from /alerts or /. This fixes https://github.com/prometheus/prometheus/issues/607 --- web/web.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/web.go b/web/web.go index 91e5b7ee..62a0fad4 100644 --- a/web/web.go +++ b/web/web.go @@ -46,7 +46,16 @@ func (w WebService) ServeForever() error { http.Error(w, "", 404) })) - http.Handle("/", prometheus.InstrumentHandler("index", w.AlertsHandler)) + http.HandleFunc("/", prometheus.InstrumentHandlerFunc("index", func(rw http.ResponseWriter, req *http.Request) { + // The "/" pattern matches everything, so we need to check + // that we're at the root here. + if req.URL.Path != "/" { + http.NotFound(rw, req) + return + } + w.AlertsHandler.ServeHTTP(rw, req) + })) + http.Handle("/alerts", prometheus.InstrumentHandler("alerts", w.AlertsHandler)) http.Handle("/silences", prometheus.InstrumentHandler("silences", w.SilencesHandler)) http.Handle("/status", prometheus.InstrumentHandler("status", w.StatusHandler))