send back more information on /game/list/
This commit is contained in:
parent
45cc67a5f1
commit
f9b646e50c
18
http.go
18
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)
|
||||
|
Loading…
Reference in New Issue
Block a user