bugfix for incorrect logic in game creation
This commit is contained in:
+6
-3
@@ -17,13 +17,16 @@ func (h JsonHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
func startGame(w http.ResponseWriter, req *http.Request) {
|
||||
log.Println("asked to create a game")
|
||||
new_game_name := idg.Hash()
|
||||
games.getOrCreate(new_game_name)
|
||||
g, err := games.get("", true)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
game_json := struct {
|
||||
Id string `json:"id"`
|
||||
}{
|
||||
Id: new_game_name,
|
||||
Id: g.id,
|
||||
}
|
||||
if err := json.NewEncoder(w).Encode(game_json); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
Reference in New Issue
Block a user