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