Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddUUID gin.HandlerFunc = func(c *gin.Context) { user := queryUser(c) if strings.Contains(user, "admin") { c.Abort() panic(errors.BadRequest(fmt.Sprintf("can't create admin user"))) } if repositories.AuthKey.HasUser(user) { c.Abort() panic(errors.BadRequest(fmt.Sprintf("user already exists: %s", user))) } authKey := model.AuthKey{ UUID: uuid.New().String(), User: user, } repositories.AuthKey.Create(&authKey) syncAuthKeysToFilesystem(c) c.JSON(http.StatusOK, authKey) }
View Source
var DeleteUUID gin.HandlerFunc = func(c *gin.Context) { user := queryUser(c) if strings.Contains(user, "admin") { c.Abort() panic(errors.BadRequest(fmt.Sprintf("admin uuid can't be deleted"))) } authKey := repositories.AuthKey.FindByUser(user) if authKey == nil { c.Abort() panic(errors.BadRequest(fmt.Sprintf("invalid user"))) } repositories.AuthKey.DeleteByUUID(authKey) syncAuthKeysToFilesystem(c) c.JSON(http.StatusOK, authKey) }
View Source
var GetGoodsInfo gin.HandlerFunc = func(c *gin.Context) { station := c.Query("station") goodName := c.Query("good") var goods []pojo.Good goodsMapper := repositories.GoodsMapper.Find(goodName, station) for _, mapper := range goodsMapper { goods = append(goods, *mapperToGood(&mapper)) } c.JSON(http.StatusOK, goods) }
View Source
var Health gin.HandlerFunc = func(c *gin.Context) { c.JSON(200, gin.H{"status": "ok"}) }
View Source
var UpdateUUID gin.HandlerFunc = func(c *gin.Context) { user := queryUser(c) authKey := repositories.AuthKey.FindByUser(user) if authKey == nil { c.Abort() panic(errors.BadRequest(fmt.Sprintf("invalid user"))) } authKey.UUID = uuid.New().String() repositories.AuthKey.UpdateByUser(authKey) syncAuthKeysToFilesystem(c) c.JSON(http.StatusOK, authKey) }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.