mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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:
committed by
GitHub
parent
a07cc0df76
commit
81324cf37c
@@ -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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user