From f9b646e50c41dc0c5d36bedf945fad8caae0624e Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Thu, 5 Sep 2013 23:31:24 -0700 Subject: [PATCH] send back more information on /game/list/ --- http.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/http.go b/http.go index afc11ce..d1240f1 100644 --- a/http.go +++ b/http.go @@ -33,9 +33,21 @@ func startGame(w http.ResponseWriter, req *http.Request) { func listGames(w http.ResponseWriter, req *http.Request) { games.RLock() defer games.RUnlock() - ids := make([]string, 0) - for id, _ := range games.m { - ids = append(ids, id) + type gl struct { + Id string `json:"id"` + Players []string `json:"players"` + } + ids := make([]gl, 0) + for id, g := range games.m { + players := make([]string, 0) + for p, _ := range g.players { + // XXX: change this to be the user-provided bot name? + players = append(players, p.Robot.Id) + } + ids = append(ids, gl{ + Id: id, + Players: players, + }) } if err := json.NewEncoder(w).Encode(ids); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError)