コード例 #1
0
ファイル: games_controller.go プロジェクト: zannet/hangman
func (this GamesController) Show(ginContext *gin.Context) {
	game, err := models.Game{}.Find(this.Context.AeContext, ginContext.Params.ByName("id"), this.Player())

	game.Url = this.ResourceUrl(baseURL, game.Id)

	if err.Any() {
		this.RespondWith.UnexpectedError(err)
		return
	}

	this.RespondWith.JSON(http.StatusOK, game)
}
コード例 #2
0
ファイル: games_controller.go プロジェクト: zannet/hangman
func (this GamesController) Create(ginContext *gin.Context) {
	game, err := models.Game{}.Create(this.Context.AeContext, this.Player())

	game.Url = this.ResourceUrl(baseURL, game.Id)

	if err.Any() {
		this.RespondWith.UnexpectedError(err)
		return
	}

	ginContext.Header("location", game.Url)
	ginContext.JSON(http.StatusCreated, game)
}