Filter repositories route by work if defined
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
0ab96472e4
commit
f615d0b8d8
|
@ -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
|
||||
|
|
Reference in New Issue