diff --git a/tsconsensus/http.go b/tsconsensus/http.go index 709bcb86b..d4715612c 100644 --- a/tsconsensus/http.go +++ b/tsconsensus/http.go @@ -113,11 +113,7 @@ func (h authedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (c *Consensus) makeCommandMux() *http.ServeMux { mux := http.NewServeMux() - mux.HandleFunc("/join", func(w http.ResponseWriter, r *http.Request) { - if r.Method != httpm.POST { - http.Error(w, "Method must be POST", http.StatusMethodNotAllowed) - return - } + mux.HandleFunc("POST /join", func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() decoder := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1024*1024)) var jr joinRequest @@ -146,11 +142,7 @@ func (c *Consensus) makeCommandMux() *http.ServeMux { return } }) - mux.HandleFunc("/executeCommand", func(w http.ResponseWriter, r *http.Request) { - if r.Method != httpm.POST { - http.Error(w, "Bad Request", http.StatusBadRequest) - return - } + mux.HandleFunc("POST /executeCommand", func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() decoder := json.NewDecoder(r.Body) var cmd Command diff --git a/tsconsensus/monitor.go b/tsconsensus/monitor.go index e1644348a..a475b1e71 100644 --- a/tsconsensus/monitor.go +++ b/tsconsensus/monitor.go @@ -47,10 +47,10 @@ func serveMonitor(c *Consensus, ts *tsnet.Server, listenAddr string) (*http.Serv } m := &monitor{con: c, ts: ts} mux := http.NewServeMux() - mux.HandleFunc("/full", m.handleFullStatus) - mux.HandleFunc("/", m.handleSummaryStatus) - mux.HandleFunc("/netmap", m.handleNetmap) - mux.HandleFunc("/dial", m.handleDial) + mux.HandleFunc("GET /full", m.handleFullStatus) + mux.HandleFunc("GET /{$}", m.handleSummaryStatus) + mux.HandleFunc("GET /netmap", m.handleNetmap) + mux.HandleFunc("POST /dial", m.handleDial) srv := &http.Server{Handler: mux} go func() { err := srv.Serve(ln)