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