Пример #1
0
func (this *GameController) Post() {
	object, err := game.Add()
	if err == nil {
		this.SetSession("GameObjectId", object.ObjectId)
		this.Data["json"] = &GameResponse{object, game.GetVariant(object), nil, "ready"}
	} else {
		this.Data["json"] = map[string]string{"error": fmt.Sprint(err)}
	}

	this.ServeJson()
}
Пример #2
0
func (this *GameController) Post() {
	object, err := game.Add()
	if err == nil {
		cookie := http.Cookie{Name: "GameObjectId",
			Value:    url.QueryEscape(object.ObjectId),
			Path:     "/",
			HttpOnly: true,
			Secure:   false,
			Expires:  time.Now().Add(time.Duration(31*24*3600) * time.Second)}
		http.SetCookie(this.Ctx.ResponseWriter, &cookie)

		this.Data["json"] = &GameResponse{object, game.GetVariant(object), nil, "ready"}
	} else {
		this.Data["json"] = map[string]string{"error": fmt.Sprint(err)}
	}

	this.ServeJson()
}