forked from forgejo/forgejo
Add pagination headers on endpoints that support total count from database (#11145)
* begin work * import fmt * more work * empty commit Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
a07cc0df76
commit
81324cf37c
9 changed files with 51 additions and 14 deletions
|
@ -208,8 +208,10 @@ func getCommitStatuses(ctx *context.APIContext, sha string) {
|
|||
}
|
||||
repo := ctx.Repo.Repository
|
||||
|
||||
statuses, _, err := models.GetCommitStatuses(repo, sha, &models.CommitStatusOptions{
|
||||
ListOptions: utils.GetListOptions(ctx),
|
||||
listOptions := utils.GetListOptions(ctx)
|
||||
|
||||
statuses, maxResults, err := models.GetCommitStatuses(repo, sha, &models.CommitStatusOptions{
|
||||
ListOptions: listOptions,
|
||||
SortType: ctx.QueryTrim("sort"),
|
||||
State: ctx.QueryTrim("state"),
|
||||
})
|
||||
|
@ -223,6 +225,9 @@ func getCommitStatuses(ctx *context.APIContext, sha string) {
|
|||
apiStatuses = append(apiStatuses, status.APIFormat())
|
||||
}
|
||||
|
||||
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
|
||||
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults))
|
||||
|
||||
ctx.JSON(http.StatusOK, apiStatuses)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue