diff --git a/app/vmalert/web.go b/app/vmalert/web.go index ae9c15616..8ca37270c 100644 --- a/app/vmalert/web.go +++ b/app/vmalert/web.go @@ -37,7 +37,7 @@ func initLinks() { {"/-/reload", "reload configuration"}, } navItems = []tpl.NavItem{ - {Name: "vmalert", Url: "home"}, + {Name: "vmalert", Url: "."}, {Name: "Groups", Url: "groups"}, {Name: "Alerts", Url: "alerts"}, {Name: "Notifiers", Url: "notifiers"}, @@ -67,8 +67,9 @@ func (rh *requestHandler) handler(w http.ResponseWriter, r *http.Request) bool { } switch r.URL.Path { - case "/", "/vmalert", "/vmalert/home": + case "/", "/vmalert", "/vmalert/": if r.Method != "GET" { + httpserver.Errorf(w, r, "path %q supports only GET method", r.URL.Path) return false } WriteWelcome(w, r) @@ -146,6 +147,7 @@ func (rh *requestHandler) handler(w http.ResponseWriter, r *http.Request) bool { // TODO: to remove in next versions if !strings.HasSuffix(r.URL.Path, "/status") { + httpserver.Errorf(w, r, "unsupported path requested: %q ", r.URL.Path) return false } alert, err := rh.alertByPath(strings.TrimPrefix(r.URL.Path, "/api/v1/")) diff --git a/app/vmalert/web_test.go b/app/vmalert/web_test.go index af77967ec..6271c2a64 100644 --- a/app/vmalert/web_test.go +++ b/app/vmalert/web_test.go @@ -52,7 +52,6 @@ func TestHandler(t *testing.T) { t.Run("/", func(t *testing.T) { getResp(ts.URL, nil, 200) getResp(ts.URL+"/vmalert", nil, 200) - getResp(ts.URL+"/vmalert/home", nil, 200) }) t.Run("/api/v1/alerts", func(t *testing.T) { diff --git a/app/vmselect/main.go b/app/vmselect/main.go index ee662d546..d748282d2 100644 --- a/app/vmselect/main.go +++ b/app/vmselect/main.go @@ -212,7 +212,11 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool { return true } - if strings.HasPrefix(path, "/vmalert") { + if path == "/vmalert" { + http.Redirect(w, r, path+"/", http.StatusMovedPermanently) + return true + } + if strings.HasPrefix(path, "/vmalert/") { vmalertRequests.Inc() if len(*vmalertProxyURL) == 0 { w.WriteHeader(http.StatusBadRequest)