From 3fe10ccb57aa9d0c96fea062154528a8214636e6 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Sun, 27 Apr 2014 13:10:38 -0600 Subject: [PATCH] agent: Redirect to UI if we have one --- command/agent/http.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/command/agent/http.go b/command/agent/http.go index ee90803d3d..fd60d6e8c8 100644 --- a/command/agent/http.go +++ b/command/agent/http.go @@ -141,11 +141,20 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque // Renders a simple index page func (s *HTTPServer) Index(resp http.ResponseWriter, req *http.Request) { - if req.URL.Path == "/" { - resp.Write([]byte("Consul Agent")) - } else { + // Check if this is a non-index path + if req.URL.Path != "/" { resp.WriteHeader(404) + return } + + // Check if we have no UI configured + if s.uiDir == "" { + resp.Write([]byte("Consul Agent")) + return + } + + // Redirect to the UI endpoint + http.Redirect(resp, req, "/ui/", 301) } // decodeBody is used to decode a JSON request body