本文整理匯總了Golang中github.com/gamescores/gin.Context類的典型用法代碼示例。如果您正苦於以下問題:Golang Context類的具體用法?Golang Context怎麽用?Golang Context使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Context類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: prepareImportScoreBoardV1
func (as AdminService) prepareImportScoreBoardV1(c *gin.Context) {
importDefinition := domain.ScoreBoardV1Import{}
importDefinition.AddLink(relImport, "/api/admin/import/scoreboardv1")
c.JSON(200, importDefinition)
}
示例2: handleGetAllPlayers
func (ps PlayerService) handleGetAllPlayers(c *gin.Context) {
var currentPage = getCurrentPage(c)
var recordsPerPage = 50
var start = getStartRecord(currentPage, recordsPerPage)
playerDao := dao.CreatePlayerDao(c)
playerArray, totalPlayerCount, err := playerDao.GetPlayers(start, recordsPerPage)
if err != nil {
utils.GetGaeContext(c).Errorf("Error loading players: %v", err)
c.AbortWithError(500, err)
return
}
if playerArray == nil {
playerArray = []domain.Player{}
}
for index := range playerArray {
addPlayerLinks(&playerArray[index], c)
}
players := &domain.Players{
Players: playerArray,
}
addPaginationLinks(players, "/api/players", currentPage, recordsPerPage, totalPlayerCount)
if isAuthenticated(c) {
players.AddLink(domain.RelCreate, "/api/players")
}
c.JSON(200, players)
}
示例3: getLeagues
func (ls LeagueService) getLeagues(c *gin.Context) {
var currentPage = getCurrentPage(c)
var recordsPerPage = 50
var start = getStartRecord(currentPage, recordsPerPage)
leagueDao := dao.CreateLeagueDao(c)
leagueArray, totalLeagueCount, err := leagueDao.GetLeagues(start, recordsPerPage)
if err != nil {
c.AbortWithError(500, err)
return
}
if leagueArray == nil {
leagueArray = []domain.League{}
}
for index := range leagueArray {
addLeagueLinks(&leagueArray[index], c)
}
leagues := &domain.Leagues{
Leagues: leagueArray,
}
addPaginationLinks(leagues, "/api/leagues", currentPage, recordsPerPage, totalLeagueCount)
if isAuthenticated(c) {
leagues.AddLink(domain.RelCreate, "/api/leagues")
}
c.JSON(200, leagues)
}
示例4: checkID
func (cds contextDefinitionService) checkID(c *gin.Context) {
var checkResult struct {
ID string `json:"id"`
IDAvailable bool `json:"available"`
Valid bool `json:"valid"`
}
checkResult.ID = c.Params.ByName("id")
if cds._isIDValid(checkResult.ID) {
contextDefinitionDao := createContextDefinitionDao(c)
idExists, err := contextDefinitionDao.checkIDExists(checkResult.ID)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
checkResult.IDAvailable = idExists == false
checkResult.Valid = true
} else {
checkResult.Valid = false
}
c.JSON(http.StatusOK, checkResult)
}
示例5: updateGame
func (gs GameService) updateGame(c *gin.Context) {
var game domain.Game
c.Bind(&game)
gs.doSaveGame(game, c)
}
示例6: updatePlayer
func (ps PlayerService) updatePlayer(c *gin.Context) {
var player domain.Player
c.Bind(&player)
ps.doSavePlayer(player, c)
}
示例7: updateLeague
func (ls LeagueService) updateLeague(c *gin.Context) {
var league domain.League
c.Bind(&league)
ls.doSaveLeague(league, c)
}
示例8: prepareNewContext
func (cds contextDefinitionService) prepareNewContext(c *gin.Context) {
newContextDefinition := ContextDefinition{}
newContextDefinition.Active = true
newContextDefinition.AddLink(relCheckID, "/api/context/checkid/")
newContextDefinition.AddLink(relCreate, "/api/context")
c.JSON(http.StatusOK, newContextDefinition)
}
示例9: createLeague
func (ls LeagueService) createLeague(c *gin.Context) {
var league domain.League
c.Bind(&league)
league.ID = 0
league.Active = true
ls.doSaveLeague(league, c)
}
示例10: createPlayer
func (ps PlayerService) createPlayer(c *gin.Context) {
var player domain.Player
c.Bind(&player)
player.ID = 0
player.Active = true
ps.doSavePlayer(player, c)
}
示例11: doSaveLeague
func (ls LeagueService) doSaveLeague(league domain.League, c *gin.Context) {
leagueDao := dao.CreateLeagueDao(c)
savedLeague, err := leagueDao.SaveLeague(league)
if err != nil {
c.AbortWithError(500, err)
}
addLeagueLinks(savedLeague, c)
c.JSON(200, savedLeague)
}
示例12: startLoginProcess
func (us UserService) startLoginProcess(c *gin.Context) {
gaeCtx := utils.GetGaeRootContext(c)
loginURL, err := appengineuser.LoginURL(gaeCtx, "")
if err != nil {
c.AbortWithError(500, err)
return
}
c.Redirect(302, loginURL)
}
示例13: createGame
func (gs GameService) createGame(c *gin.Context) {
leagueID := getLeagueIDFromURL(c)
var game domain.Game
c.Bind(&game)
game.ID = 0
game.LeagueID = leagueID
gs.doSaveGame(game, c)
}
示例14: doSaveGame
func (gs GameService) doSaveGame(game domain.Game, c *gin.Context) {
gameDao := dao.CreateGameDao(c)
savedGame, err := gameDao.SaveGame(game)
if err != nil {
utils.GetGaeContext(c).Errorf("Error saving game: %v", err)
c.AbortWithError(500, err)
}
gs.addGameLinks(game.LeagueID, savedGame, c)
c.JSON(200, savedGame)
}
示例15: doSavePlayer
func (ps PlayerService) doSavePlayer(player domain.Player, c *gin.Context) {
playerDao := dao.CreatePlayerDao(c)
savedPlayer, err := playerDao.SavePlayer(player)
if err != nil {
utils.GetGaeContext(c).Errorf("Error saving player: %v", err)
c.AbortWithError(500, err)
}
addPlayerLinks(savedPlayer, c)
c.JSON(200, savedPlayer)
}