// Handles incoming AppendEntries requests. func (t *HTTPTransporter) appendEntriesHandler(server raft.Server) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { //log.Println(server.Name(), "RECV /appendEntries") req := &raft.AppendEntriesRequest{} if _, err := req.Decode(r.Body); err != nil { http.Error(w, "", http.StatusBadRequest) return } resp := server.AppendEntries(req) if _, err := resp.Encode(w); err != nil { http.Error(w, "", http.StatusInternalServerError) return } } }