Mock repository update
This commit is contained in:
parent
3285d5e896
commit
8d9245f1b1
3 changed files with 33 additions and 3 deletions
|
|
@ -111,6 +111,22 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
|||
c.JSON(http.StatusOK, nil)
|
||||
}
|
||||
})
|
||||
|
||||
repositoriesRoutes.POST("/trigger", func(c *gin.Context) {
|
||||
repo := c.MustGet("repository").(*Repository)
|
||||
|
||||
now := time.Now()
|
||||
|
||||
if !repo.LastCheck.Before(now.Add(-5 * time.Minute)) {
|
||||
c.AbortWithStatusJSON(http.StatusPaymentRequired, gin.H{"errmsg": "Please wait between two pulls."})
|
||||
return
|
||||
}
|
||||
|
||||
repo.LastCheck = &now
|
||||
repo.Update()
|
||||
|
||||
c.JSON(http.StatusOK, repo)
|
||||
})
|
||||
}
|
||||
|
||||
func repositoryHandler(c *gin.Context) {
|
||||
|
|
|
|||
Reference in a new issue