From 9b679de9dd2a81610537f145f61aec8cf092b747 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Thu, 23 Oct 2014 22:52:39 -0700 Subject: [PATCH] etcdserver/etcdhttp: use container for admin/members endpoint --- etcdserver/etcdhttp/http.go | 6 +++++- etcdserver/etcdhttp/http_test.go | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/etcdserver/etcdhttp/http.go b/etcdserver/etcdhttp/http.go index 322665d01..d751ffc0f 100644 --- a/etcdserver/etcdhttp/http.go +++ b/etcdserver/etcdhttp/http.go @@ -163,7 +163,11 @@ func (h serverHandler) serveAdminMembers(w http.ResponseWriter, r *http.Request) case "GET": idStr := strings.TrimPrefix(r.URL.Path, adminMembersPrefix) if idStr == "" { - ms := h.clusterInfo.Members() + ms := struct { + Members []*etcdserver.Member + }{ + Members: h.clusterInfo.Members(), + } w.Header().Set("Content-Type", "application/json") if err := json.NewEncoder(w).Encode(ms); err != nil { log.Printf("etcdhttp: %v", err) diff --git a/etcdserver/etcdhttp/http_test.go b/etcdserver/etcdhttp/http_test.go index e6aada492..0c67b8367 100644 --- a/etcdserver/etcdhttp/http_test.go +++ b/etcdserver/etcdhttp/http_test.go @@ -1627,7 +1627,13 @@ func TestServeAdminMembers(t *testing.T) { clusterInfo: cluster, } - msb, err := json.Marshal([]etcdserver.Member{memb1, memb2}) + msb, err := json.Marshal( + struct { + Members []etcdserver.Member + }{ + Members: []etcdserver.Member{memb1, memb2}, + }, + ) if err != nil { t.Fatal(err) }