mirror of https://github.com/status-im/consul.git
agent: Redirect to UI if we have one
This commit is contained in:
parent
71ae55f665
commit
3fe10ccb57
|
@ -141,11 +141,20 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque
|
||||||
|
|
||||||
// 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) {
|
||||||
if req.URL.Path == "/" {
|
// Check if this is a non-index path
|
||||||
resp.Write([]byte("Consul Agent"))
|
if req.URL.Path != "/" {
|
||||||
} else {
|
|
||||||
resp.WriteHeader(404)
|
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
|
// decodeBody is used to decode a JSON request body
|
||||||
|
|
Loading…
Reference in New Issue