From e79dd7c8de04fb71090a51a37f39bb5a2478f2d5 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Fri, 12 Feb 2016 16:11:32 -0800 Subject: [PATCH] Fixes redirect from / to /ui when internal UI is enabled. --- command/agent/http.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/command/agent/http.go b/command/agent/http.go index 501b95c57d..749ed0ef0e 100644 --- a/command/agent/http.go +++ b/command/agent/http.go @@ -363,6 +363,11 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque return f } +// Returns true if the UI is enabled. +func (s *HTTPServer) IsUIEnabled() bool { + return s.uiDir != "" || s.agent.config.EnableUi +} + // Renders a simple index page func (s *HTTPServer) Index(resp http.ResponseWriter, req *http.Request) { // Check if this is a non-index path @@ -371,8 +376,9 @@ func (s *HTTPServer) Index(resp http.ResponseWriter, req *http.Request) { return } - // Check if we have no UI configured - if s.uiDir == "" { + // Give them something helpful if there's no UI so they at least know + // what this server is. + if !s.IsUIEnabled() { resp.Write([]byte("Consul Agent")) return }