summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-08-13 18:18:18 +0100
committerGitHub <noreply@github.com>2020-08-13 18:18:18 +0100
commit2ef318e6f1d0c674e894d2d1f25ca79498663466 (patch)
tree4914d7c95e814af2ffdc8ea7101b6f1b86e03ae4 /routers/api
parente266ba30cca17bdb5c50fd0cd30d2e429e58ac26 (diff)
downloadgitea-2ef318e6f1d0c674e894d2d1f25ca79498663466.tar.gz
gitea-2ef318e6f1d0c674e894d2d1f25ca79498663466.zip
Add Access-Control-Expose-Headers (#12446)
Fix #12424 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/admin/org.go1
-rw-r--r--routers/api/v1/admin/user.go1
-rw-r--r--routers/api/v1/org/org.go1
-rw-r--r--routers/api/v1/org/team.go1
-rw-r--r--routers/api/v1/repo/commits.go1
-rw-r--r--routers/api/v1/repo/issue.go3
-rw-r--r--routers/api/v1/repo/pull.go1
-rw-r--r--routers/api/v1/repo/repo.go1
-rw-r--r--routers/api/v1/repo/status.go1
-rw-r--r--routers/api/v1/user/repo.go2
-rw-r--r--routers/api/v1/user/user.go1
11 files changed, 14 insertions, 0 deletions
diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go
index 62d485d821..0fd9e17f41 100644
--- a/routers/api/v1/admin/org.go
+++ b/routers/api/v1/admin/org.go
@@ -121,5 +121,6 @@ func GetAllOrgs(ctx *context.APIContext) {
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, &orgs)
}
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go
index 153ce66d76..a8a573eaf0 100644
--- a/routers/api/v1/admin/user.go
+++ b/routers/api/v1/admin/user.go
@@ -370,5 +370,6 @@ func GetAllUsers(ctx *context.APIContext) {
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, &results)
}
diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go
index 1d277521cc..7577700abf 100644
--- a/routers/api/v1/org/org.go
+++ b/routers/api/v1/org/org.go
@@ -135,6 +135,7 @@ func GetAll(ctx *context.APIContext) {
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, &orgs)
}
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index 0e92f2edb8..443784fb8b 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -686,6 +686,7 @@ func SearchTeam(ctx *context.APIContext) {
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, map[string]interface{}{
"ok": true,
"data": apiTeams,
diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go
index d383cd500f..8b2dc28bdd 100644
--- a/routers/api/v1/repo/commits.go
+++ b/routers/api/v1/repo/commits.go
@@ -211,6 +211,7 @@ func GetAllCommits(ctx *context.APIContext) {
ctx.SetLinkHeader(int(commitsCountTotal), listOptions.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", commitsCountTotal))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, X-PerPage, X-Total, X-PageCount, X-HasMore, Link")
ctx.JSON(http.StatusOK, &apiCommits)
}
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index d7bd3cd356..1653b85940 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -173,6 +173,8 @@ func SearchIssues(ctx *context.APIContext) {
}
ctx.SetLinkHeader(issueCount, setting.UI.IssuePagingNum)
+ ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", issueCount))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(issues))
}
@@ -322,6 +324,7 @@ func ListIssues(ctx *context.APIContext) {
ctx.SetLinkHeader(ctx.Repo.Repository.NumIssues, listOptions.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", ctx.Repo.Repository.NumIssues))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(issues))
}
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 5fc0cd8cfb..21cc048a69 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -115,6 +115,7 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, &apiPrs)
}
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index f812ac6788..93898cd7ef 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -222,6 +222,7 @@ func Search(ctx *context.APIContext) {
ctx.SetLinkHeader(int(count), opts.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", count))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, api.SearchResults{
OK: true,
Data: results,
diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go
index 11af4a0d1b..69661dca91 100644
--- a/routers/api/v1/repo/status.go
+++ b/routers/api/v1/repo/status.go
@@ -227,6 +227,7 @@ func getCommitStatuses(ctx *context.APIContext, sha string) {
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, apiStatuses)
}
diff --git a/routers/api/v1/user/repo.go b/routers/api/v1/user/repo.go
index dbd18f133d..ae5e319c27 100644
--- a/routers/api/v1/user/repo.go
+++ b/routers/api/v1/user/repo.go
@@ -43,6 +43,7 @@ func listUserRepos(ctx *context.APIContext, u *models.User, private bool) {
ctx.SetLinkHeader(int(count), opts.PageSize)
ctx.Header().Set("X-Total-Count", strconv.FormatInt(count, 10))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, &apiRepos)
}
@@ -129,6 +130,7 @@ func ListMyRepos(ctx *context.APIContext) {
ctx.SetLinkHeader(int(count), opts.ListOptions.PageSize)
ctx.Header().Set("X-Total-Count", strconv.FormatInt(count, 10))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, &results)
}
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go
index 426501f331..b552c1353a 100644
--- a/routers/api/v1/user/user.go
+++ b/routers/api/v1/user/user.go
@@ -82,6 +82,7 @@ func Search(ctx *context.APIContext) {
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults))
+ ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, map[string]interface{}{
"ok": true,