mirror of https://github.com/status-im/consul.git
Adding index page with 404 catchall
This commit is contained in:
parent
8cc761de17
commit
5c874584be
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue