From 5c874584bedd894f4d06516c1f628cd6f0f38e0d Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Tue, 24 Dec 2013 17:09:51 -0800 Subject: [PATCH] Adding index page with 404 catchall --- command/agent/http.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/command/agent/http.go b/command/agent/http.go index 6bdd1916f6..c70527446b 100644 --- a/command/agent/http.go +++ b/command/agent/http.go @@ -52,6 +52,8 @@ func (s *HTTPServer) Shutdown() { // registerHandlers is used to attach our handlers to the mux func (s *HTTPServer) registerHandlers() { + s.mux.HandleFunc("/", s.Index) + s.mux.HandleFunc("/v1/status/leader", s.wrap(s.StatusLeader)) s.mux.HandleFunc("/v1/status/peers", s.wrap(s.StatusPeers)) @@ -96,6 +98,15 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque return f } +// 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 { + resp.WriteHeader(404) + } +} + // decodeBody is used to decode a JSON request body func decodeBody(req *http.Request, out interface{}) error { dec := json.NewDecoder(req.Body)