Filter repositories route by work if defined
continuous-integration/drone/push Build is passing Details

This commit is contained in:
nemunaire 2022-09-16 17:26:02 +02:00
parent 0ab96472e4
commit f615d0b8d8
1 changed files with 13 additions and 1 deletions

View File

@ -55,7 +55,19 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
return
}
c.JSON(http.StatusOK, repositories)
if work, ok := c.Get("work"); ok {
var res []*Repository
for _, r := range repositories {
if r.IdWork == work.(*Work).Id {
res = append(res, r)
}
}
c.JSON(http.StatusOK, res)
} else {
c.JSON(http.StatusOK, repositories)
}
})
router.POST("/repositories", func(c *gin.Context) {
var u *User