func ResolveGameContext() gin.HandlerFunc { return func(c *gin.Context) { contextDefinitionDao := dao.CreateContextDefinitionDao(c) contextDefinition, err := contextDefinitionDao.GetContext(utils.GetNamespace(c)) if err != nil { utils.AbortWithError(c, err) return } c.Set(gameContextKey, contextDefinition) } }
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) }