Fixes redirect from / to /ui when internal UI is enabled.

This commit is contained in:
James Phillips 2016-02-12 16:11:32 -08:00
parent b7b46f9e3a
commit e79dd7c8de
1 changed files with 8 additions and 2 deletions

View File

@ -363,6 +363,11 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque
return f 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 // Renders a simple index page
func (s *HTTPServer) Index(resp http.ResponseWriter, req *http.Request) { func (s *HTTPServer) Index(resp http.ResponseWriter, req *http.Request) {
// Check if this is a non-index path // Check if this is a non-index path
@ -371,8 +376,9 @@ func (s *HTTPServer) Index(resp http.ResponseWriter, req *http.Request) {
return return
} }
// Check if we have no UI configured // Give them something helpful if there's no UI so they at least know
if s.uiDir == "" { // what this server is.
if !s.IsUIEnabled() {
resp.Write([]byte("Consul Agent")) resp.Write([]byte("Consul Agent"))
return return
} }