aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-12-15 14:59:57 +0800
committerGitHub <noreply@github.com>2021-12-15 14:59:57 +0800
commit4da1d9781025aa4a85899b1ddeb25aabbaa82703 (patch)
tree9714f71f2fb042e44d418fbcfc56cd8440a1bbb1 /routers/api/v1/repo
parent9d943bf374e56e4d403303a6a2caafc1c79cdb6f (diff)
downloadgitea-4da1d9781025aa4a85899b1ddeb25aabbaa82703.tar.gz
gitea-4da1d9781025aa4a85899b1ddeb25aabbaa82703.zip
Refactor HTTP request context (#17979)
Diffstat (limited to 'routers/api/v1/repo')
-rw-r--r--routers/api/v1/repo/commits.go10
-rw-r--r--routers/api/v1/repo/pull.go8
2 files changed, 9 insertions, 9 deletions
diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go
index 117fef08da..6845ccb363 100644
--- a/routers/api/v1/repo/commits.go
+++ b/routers/api/v1/repo/commits.go
@@ -205,11 +205,11 @@ func GetAllCommits(ctx *context.APIContext) {
ctx.SetTotalCountHeader(commitsCountTotal)
// kept for backwards compatibility
- ctx.Header().Set("X-Page", strconv.Itoa(listOptions.Page))
- ctx.Header().Set("X-PerPage", strconv.Itoa(listOptions.PageSize))
- ctx.Header().Set("X-Total", strconv.FormatInt(commitsCountTotal, 10))
- ctx.Header().Set("X-PageCount", strconv.Itoa(pageCount))
- ctx.Header().Set("X-HasMore", strconv.FormatBool(listOptions.Page < pageCount))
+ ctx.RespHeader().Set("X-Page", strconv.Itoa(listOptions.Page))
+ ctx.RespHeader().Set("X-PerPage", strconv.Itoa(listOptions.PageSize))
+ ctx.RespHeader().Set("X-Total", strconv.FormatInt(commitsCountTotal, 10))
+ ctx.RespHeader().Set("X-PageCount", strconv.Itoa(pageCount))
+ ctx.RespHeader().Set("X-HasMore", strconv.FormatBool(listOptions.Page < pageCount))
ctx.AppendAccessControlExposeHeaders("X-Page", "X-PerPage", "X-Total", "X-PageCount", "X-HasMore")
ctx.JSON(http.StatusOK, &apiCommits)
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 0683fe4548..4c774e8af7 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -1233,10 +1233,10 @@ func GetPullRequestCommits(ctx *context.APIContext) {
ctx.SetLinkHeader(totalNumberOfCommits, listOptions.PageSize)
ctx.SetTotalCountHeader(int64(totalNumberOfCommits))
- ctx.Header().Set("X-Page", strconv.Itoa(listOptions.Page))
- ctx.Header().Set("X-PerPage", strconv.Itoa(listOptions.PageSize))
- ctx.Header().Set("X-PageCount", strconv.Itoa(totalNumberOfPages))
- ctx.Header().Set("X-HasMore", strconv.FormatBool(listOptions.Page < totalNumberOfPages))
+ ctx.RespHeader().Set("X-Page", strconv.Itoa(listOptions.Page))
+ ctx.RespHeader().Set("X-PerPage", strconv.Itoa(listOptions.PageSize))
+ ctx.RespHeader().Set("X-PageCount", strconv.Itoa(totalNumberOfPages))
+ ctx.RespHeader().Set("X-HasMore", strconv.FormatBool(listOptions.Page < totalNumberOfPages))
ctx.AppendAccessControlExposeHeaders("X-Page", "X-PerPage", "X-PageCount", "X-HasMore")
ctx.JSON(http.StatusOK, &apiCommits)