本文整理匯總了Golang中github.com/gamescores/gin.Context.Bind方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Bind方法的具體用法?Golang Context.Bind怎麽用?Golang Context.Bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gamescores/gin.Context
的用法示例。
在下文中一共展示了Context.Bind方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updateGame
func (gs GameService) updateGame(c *gin.Context) {
var game domain.Game
c.Bind(&game)
gs.doSaveGame(game, c)
}
示例2: updateLeague
func (ls LeagueService) updateLeague(c *gin.Context) {
var league domain.League
c.Bind(&league)
ls.doSaveLeague(league, c)
}
示例3: updatePlayer
func (ps PlayerService) updatePlayer(c *gin.Context) {
var player domain.Player
c.Bind(&player)
ps.doSavePlayer(player, c)
}
示例4: saveContext
func (cds contextDefinitionService) saveContext(c *gin.Context) {
var contextDefinition ContextDefinition
c.Bind(&contextDefinition)
if !cds._isValid(contextDefinition) {
c.AbortWithStatus(http.StatusBadRequest)
return
}
user := getCurrentUserFromGinContext(c)
// Run all of this in a transaction (even if we are on service level)
err := datastore.RunInTransaction(getGaeContext(c), func(gaeCtx appengine.Context) error {
contextDao := contextDefinitionDao{dao{gaeCtx}}
idExists, err := contextDao.checkIDExists(contextDefinition.ID)
if err != nil {
return err
}
if idExists {
return ErrIDAlreadyExists
}
contextDefinition.Owner = datastore.NewKey(gaeCtx, entityUser, user.UserID, 0, nil)
contextDefinition.Active = true
err = contextDao.saveContext(contextDefinition)
if err != nil {
return err
}
return nil
}, &datastore.TransactionOptions{
XG: true,
})
if err != nil {
returnStatus := http.StatusInternalServerError
if err == ErrIDAlreadyExists {
returnStatus = http.StatusConflict
}
c.AbortWithError(returnStatus, err)
return
}
contextDefinition.RemoveLink(relCreate)
contextDefinition.RemoveLink(relCheckID)
if productionDomain := os.Getenv("PRODUCTION_DOMAIN"); productionDomain != "" {
contextDefinition.AddLink(relSelf, fmt.Sprintf("http://%s.%s", contextDefinition.ID, productionDomain))
}
c.JSON(200, contextDefinition)
}
示例5: 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)
}
示例6: 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)
}
示例7: 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)
}
示例8: importScoreBoardV1
func (as AdminService) importScoreBoardV1(c *gin.Context) {
var importDefinition domain.ScoreBoardV1Import
c.Bind(&importDefinition)
if importDefinition.DbDumpUrl == "" {
c.AbortWithStatus(http.StatusBadRequest)
return
}
createTask := &taskqueue.Task{
Path: "/tasks/import/scoreboardv1",
Payload: []byte(importDefinition.DbDumpUrl),
}
hostName, _ := appengine.ModuleHostname(utils.GetGaeRootContext(c), appengine.ModuleName(utils.GetGaeRootContext(c)), "", "")
createTask.Header = http.Header{}
createTask.Header.Set("Host", hostName)
createTask.Header.Set(utils.NamespaceHeader, utils.GetNamespace(c))
_, err := taskqueue.Add(utils.GetGaeRootContext(c), createTask, "contextqueue")
if err != nil {
utils.GetGaeRootContext(c).Errorf("Error calling taskqueue.Add in importScoreBoardV1: %v", err)
c.AbortWithError(http.StatusInternalServerError, err)
return
}
importDao := dao.CreateImportDao(c)
importStatus, err := importDao.SetStatus(true, 0, 0, 0, 0, 0, 0)
if err != nil {
utils.GetGaeRootContext(c).Errorf("Error calling importDao.setStatus in importScoreBoardV1: %v", err)
c.AbortWithError(http.StatusInternalServerError, err)
return
}
importStatus.AddLink(relImportStatus, "/api/admin/import/scoreboardv1/status")
c.JSON(200, importStatus)
}