get page query param. set default of 1 if not set

This commit is contained in:
Jordan Brockopp 2018-02-02 13:04:21 -06:00
parent af76d46b53
commit c84031e3e8
2 changed files with 8 additions and 2 deletions

View file

@ -72,7 +72,7 @@ func GetCC(c *gin.Context) {
return return
} }
builds, err := store.GetBuildList(c, repo) builds, err := store.GetBuildList(c, repo, 1)
if err != nil || len(builds) == 0 { if err != nil || len(builds) == 0 {
c.AbortWithStatus(404) c.AbortWithStatus(404)
return return

View file

@ -25,7 +25,13 @@ import (
func GetBuilds(c *gin.Context) { func GetBuilds(c *gin.Context) {
repo := session.Repo(c) repo := session.Repo(c)
builds, err := store.GetBuildList(c, repo) page, err := strconv.Atoi(c.DefaultQuery("page", "1"))
if err != nil {
c.AbortWithError(http.StatusBadRequest, err)
return
}
builds, err := store.GetBuildList(c, repo, page)
if err != nil { if err != nil {
c.AbortWithStatus(http.StatusInternalServerError) c.AbortWithStatus(http.StatusInternalServerError)
return return