summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-07-29 09:42:15 +0800
committerGitHub <noreply@github.com>2021-07-29 03:42:15 +0200
commit33e0b38287fdc3487112062300b8dd3c95415ee7 (patch)
tree603394d8f303de1031c21da0d3d3a3cdc0b2bfda /routers/api
parent370516883717de0e6e2087c12d368eb1465ee3b0 (diff)
downloadgitea-33e0b38287fdc3487112062300b8dd3c95415ee7.tar.gz
gitea-33e0b38287fdc3487112062300b8dd3c95415ee7.zip
Rename context.Query to context.Form (#16562)
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/admin/adopt.go2
-rw-r--r--routers/api/v1/api.go2
-rw-r--r--routers/api/v1/notify/notifications.go6
-rw-r--r--routers/api/v1/notify/repo.go8
-rw-r--r--routers/api/v1/notify/threads.go2
-rw-r--r--routers/api/v1/notify/user.go8
-rw-r--r--routers/api/v1/org/label.go2
-rw-r--r--routers/api/v1/org/team.go4
-rw-r--r--routers/api/v1/repo/commits.go2
-rw-r--r--routers/api/v1/repo/file.go4
-rw-r--r--routers/api/v1/repo/issue.go36
-rw-r--r--routers/api/v1/repo/issue_tracked_time.go4
-rw-r--r--routers/api/v1/repo/key.go4
-rw-r--r--routers/api/v1/repo/label.go2
-rw-r--r--routers/api/v1/repo/milestone.go4
-rw-r--r--routers/api/v1/repo/pull.go8
-rw-r--r--routers/api/v1/repo/release.go8
-rw-r--r--routers/api/v1/repo/release_attachment.go2
-rw-r--r--routers/api/v1/repo/repo.go36
-rw-r--r--routers/api/v1/repo/status.go6
-rw-r--r--routers/api/v1/repo/topic.go2
-rw-r--r--routers/api/v1/repo/tree.go2
-rw-r--r--routers/api/v1/user/key.go2
-rw-r--r--routers/api/v1/user/user.go4
-rw-r--r--routers/api/v1/utils/utils.go6
25 files changed, 83 insertions, 83 deletions
diff --git a/routers/api/v1/admin/adopt.go b/routers/api/v1/admin/adopt.go
index fdef94e6c8..fb5888f083 100644
--- a/routers/api/v1/admin/adopt.go
+++ b/routers/api/v1/admin/adopt.go
@@ -42,7 +42,7 @@ func ListUnadoptedRepositories(ctx *context.APIContext) {
// "$ref": "#/responses/forbidden"
listOptions := utils.GetListOptions(ctx)
- repoNames, count, err := repository.ListUnadoptedRepositories(ctx.Query("query"), &listOptions)
+ repoNames, count, err := repository.ListUnadoptedRepositories(ctx.Form("query"), &listOptions)
if err != nil {
ctx.InternalServerError(err)
}
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 4258ea5dc3..b1933366f0 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -93,7 +93,7 @@ import (
func sudo() func(ctx *context.APIContext) {
return func(ctx *context.APIContext) {
- sudo := ctx.Query("sudo")
+ sudo := ctx.Form("sudo")
if len(sudo) == 0 {
sudo = ctx.Req.Header.Get("Sudo")
}
diff --git a/routers/api/v1/notify/notifications.go b/routers/api/v1/notify/notifications.go
index a5e095a3b5..9dd9da85c5 100644
--- a/routers/api/v1/notify/notifications.go
+++ b/routers/api/v1/notify/notifications.go
@@ -37,12 +37,12 @@ func getFindNotificationOptions(ctx *context.APIContext) *models.FindNotificatio
UpdatedBeforeUnix: before,
UpdatedAfterUnix: since,
}
- if !ctx.QueryBool("all") {
- statuses := ctx.QueryStrings("status-types")
+ if !ctx.FormBool("all") {
+ statuses := ctx.FormStrings("status-types")
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread", "pinned"})
}
- subjectTypes := ctx.QueryStrings("subject-type")
+ subjectTypes := ctx.FormStrings("subject-type")
if len(subjectTypes) != 0 {
opts.Source = subjectToSource(subjectTypes)
}
diff --git a/routers/api/v1/notify/repo.go b/routers/api/v1/notify/repo.go
index af55d1d49c..b5a6d8abf0 100644
--- a/routers/api/v1/notify/repo.go
+++ b/routers/api/v1/notify/repo.go
@@ -171,7 +171,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
lastRead := int64(0)
- qLastRead := strings.Trim(ctx.Query("last_read_at"), " ")
+ qLastRead := strings.Trim(ctx.Form("last_read_at"), " ")
if len(qLastRead) > 0 {
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
if err != nil {
@@ -189,8 +189,8 @@ func ReadRepoNotifications(ctx *context.APIContext) {
UpdatedBeforeUnix: lastRead,
}
- if !ctx.QueryBool("all") {
- statuses := ctx.QueryStrings("status-types")
+ if !ctx.FormBool("all") {
+ statuses := ctx.FormStrings("status-types")
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread"})
log.Error("%v", opts.Status)
}
@@ -200,7 +200,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
return
}
- targetStatus := statusStringToNotificationStatus(ctx.Query("to-status"))
+ targetStatus := statusStringToNotificationStatus(ctx.Form("to-status"))
if targetStatus == 0 {
targetStatus = models.NotificationStatusRead
}
diff --git a/routers/api/v1/notify/threads.go b/routers/api/v1/notify/threads.go
index efe5bcb59c..0865d12156 100644
--- a/routers/api/v1/notify/threads.go
+++ b/routers/api/v1/notify/threads.go
@@ -82,7 +82,7 @@ func ReadThread(ctx *context.APIContext) {
return
}
- targetStatus := statusStringToNotificationStatus(ctx.Query("to-status"))
+ targetStatus := statusStringToNotificationStatus(ctx.Form("to-status"))
if targetStatus == 0 {
targetStatus = models.NotificationStatusRead
}
diff --git a/routers/api/v1/notify/user.go b/routers/api/v1/notify/user.go
index 475a541bdc..184091544a 100644
--- a/routers/api/v1/notify/user.go
+++ b/routers/api/v1/notify/user.go
@@ -122,7 +122,7 @@ func ReadNotifications(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
lastRead := int64(0)
- qLastRead := strings.Trim(ctx.Query("last_read_at"), " ")
+ qLastRead := strings.Trim(ctx.Form("last_read_at"), " ")
if len(qLastRead) > 0 {
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
if err != nil {
@@ -137,8 +137,8 @@ func ReadNotifications(ctx *context.APIContext) {
UserID: ctx.User.ID,
UpdatedBeforeUnix: lastRead,
}
- if !ctx.QueryBool("all") {
- statuses := ctx.QueryStrings("status-types")
+ if !ctx.FormBool("all") {
+ statuses := ctx.FormStrings("status-types")
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread"})
}
nl, err := models.GetNotifications(opts)
@@ -147,7 +147,7 @@ func ReadNotifications(ctx *context.APIContext) {
return
}
- targetStatus := statusStringToNotificationStatus(ctx.Query("to-status"))
+ targetStatus := statusStringToNotificationStatus(ctx.Form("to-status"))
if targetStatus == 0 {
targetStatus = models.NotificationStatusRead
}
diff --git a/routers/api/v1/org/label.go b/routers/api/v1/org/label.go
index 76061f163a..a66977ea5a 100644
--- a/routers/api/v1/org/label.go
+++ b/routers/api/v1/org/label.go
@@ -43,7 +43,7 @@ func ListLabels(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/LabelList"
- labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.Query("sort"), utils.GetListOptions(ctx))
+ labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.Form("sort"), utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByOrgID", err)
return
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index bc86bbcbe3..e967fc7612 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -658,9 +658,9 @@ func SearchTeam(ctx *context.APIContext) {
opts := &models.SearchTeamOptions{
UserID: ctx.User.ID,
- Keyword: strings.TrimSpace(ctx.Query("q")),
+ Keyword: strings.TrimSpace(ctx.Form("q")),
OrgID: ctx.Org.Organization.ID,
- IncludeDesc: ctx.Query("include_desc") == "" || ctx.QueryBool("include_desc"),
+ IncludeDesc: ctx.Form("include_desc") == "" || ctx.FormBool("include_desc"),
ListOptions: listOptions,
}
diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go
index 9a0fd1d0b6..e4bea4dee7 100644
--- a/routers/api/v1/repo/commits.go
+++ b/routers/api/v1/repo/commits.go
@@ -147,7 +147,7 @@ func GetAllCommits(ctx *context.APIContext) {
listOptions.PageSize = setting.Git.CommitsRangeSize
}
- sha := ctx.Query("sha")
+ sha := ctx.Form("sha")
var baseCommit *git.Commit
if len(sha) == 0 {
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index e6427ea4f4..2b14d1a93c 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -62,7 +62,7 @@ func GetRawFile(ctx *context.APIContext) {
commit := ctx.Repo.Commit
- if ref := ctx.QueryTrim("ref"); len(ref) > 0 {
+ if ref := ctx.FormTrim("ref"); len(ref) > 0 {
var err error
commit, err = ctx.Repo.GitRepo.GetCommit(ref)
if err != nil {
@@ -549,7 +549,7 @@ func GetContents(ctx *context.APIContext) {
}
treePath := ctx.Params("*")
- ref := ctx.QueryTrim("ref")
+ ref := ctx.FormTrim("ref")
if fileList, err := repofiles.GetContentsOrList(ctx.Repo.Repository, treePath, ref); err != nil {
if git.IsErrNotExist(err) {
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index 5a7d10b36f..172ad48031 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -106,7 +106,7 @@ func SearchIssues(ctx *context.APIContext) {
}
var isClosed util.OptionalBool
- switch ctx.Query("state") {
+ switch ctx.Form("state") {
case "closed":
isClosed = util.OptionalBoolTrue
case "all":
@@ -140,7 +140,7 @@ func SearchIssues(ctx *context.APIContext) {
var issues []*models.Issue
var filteredCount int64
- keyword := strings.Trim(ctx.Query("q"), " ")
+ keyword := strings.Trim(ctx.Form("q"), " ")
if strings.IndexByte(keyword, 0) >= 0 {
keyword = ""
}
@@ -153,7 +153,7 @@ func SearchIssues(ctx *context.APIContext) {
}
var isPull util.OptionalBool
- switch ctx.Query("type") {
+ switch ctx.Form("type") {
case "pulls":
isPull = util.OptionalBoolTrue
case "issues":
@@ -162,13 +162,13 @@ func SearchIssues(ctx *context.APIContext) {
isPull = util.OptionalBoolNone
}
- labels := strings.TrimSpace(ctx.Query("labels"))
+ labels := strings.TrimSpace(ctx.Form("labels"))
var includedLabelNames []string
if len(labels) > 0 {
includedLabelNames = strings.Split(labels, ",")
}
- milestones := strings.TrimSpace(ctx.Query("milestones"))
+ milestones := strings.TrimSpace(ctx.Form("milestones"))
var includedMilestones []string
if len(milestones) > 0 {
includedMilestones = strings.Split(milestones, ",")
@@ -176,7 +176,7 @@ func SearchIssues(ctx *context.APIContext) {
// this api is also used in UI,
// so the default limit is set to fit UI needs
- limit := ctx.QueryInt("limit")
+ limit := ctx.FormInt("limit")
if limit == 0 {
limit = setting.UI.IssuePagingNum
} else if limit > setting.API.MaxResponseItems {
@@ -188,7 +188,7 @@ func SearchIssues(ctx *context.APIContext) {
if len(keyword) == 0 || len(issueIDs) > 0 || len(includedLabelNames) > 0 || len(includedMilestones) > 0 {
issuesOpt := &models.IssuesOptions{
ListOptions: models.ListOptions{
- Page: ctx.QueryInt("page"),
+ Page: ctx.FormInt("page"),
PageSize: limit,
},
RepoIDs: repoIDs,
@@ -197,23 +197,23 @@ func SearchIssues(ctx *context.APIContext) {
IncludedLabelNames: includedLabelNames,
IncludeMilestones: includedMilestones,
SortType: "priorityrepo",
- PriorityRepoID: ctx.QueryInt64("priority_repo_id"),
+ PriorityRepoID: ctx.FormInt64("priority_repo_id"),
IsPull: isPull,
UpdatedBeforeUnix: before,
UpdatedAfterUnix: since,
}
// Filter for: Created by User, Assigned to User, Mentioning User, Review of User Requested
- if ctx.QueryBool("created") {
+ if ctx.FormBool("created") {
issuesOpt.PosterID = ctx.User.ID
}
- if ctx.QueryBool("assigned") {
+ if ctx.FormBool("assigned") {
issuesOpt.AssigneeID = ctx.User.ID
}
- if ctx.QueryBool("mentioned") {
+ if ctx.FormBool("mentioned") {
issuesOpt.MentionedID = ctx.User.ID
}
- if ctx.QueryBool("review_requested") {
+ if ctx.FormBool("review_requested") {
issuesOpt.ReviewRequestedID = ctx.User.ID
}
@@ -319,7 +319,7 @@ func ListIssues(ctx *context.APIContext) {
}
var isClosed util.OptionalBool
- switch ctx.Query("state") {
+ switch ctx.Form("state") {
case "closed":
isClosed = util.OptionalBoolTrue
case "all":
@@ -331,7 +331,7 @@ func ListIssues(ctx *context.APIContext) {
var issues []*models.Issue
var filteredCount int64
- keyword := strings.Trim(ctx.Query("q"), " ")
+ keyword := strings.Trim(ctx.Form("q"), " ")
if strings.IndexByte(keyword, 0) >= 0 {
keyword = ""
}
@@ -345,7 +345,7 @@ func ListIssues(ctx *context.APIContext) {
}
}
- if splitted := strings.Split(ctx.Query("labels"), ","); len(splitted) > 0 {
+ if splitted := strings.Split(ctx.Form("labels"), ","); len(splitted) > 0 {
labelIDs, err = models.GetLabelIDsInRepoByNames(ctx.Repo.Repository.ID, splitted)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelIDsInRepoByNames", err)
@@ -354,7 +354,7 @@ func ListIssues(ctx *context.APIContext) {
}
var mileIDs []int64
- if part := strings.Split(ctx.Query("milestones"), ","); len(part) > 0 {
+ if part := strings.Split(ctx.Form("milestones"), ","); len(part) > 0 {
for i := range part {
// uses names and fall back to ids
// non existent milestones are discarded
@@ -386,7 +386,7 @@ func ListIssues(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx)
var isPull util.OptionalBool
- switch ctx.Query("type") {
+ switch ctx.Form("type") {
case "pulls":
isPull = util.OptionalBoolTrue
case "issues":
@@ -448,7 +448,7 @@ func ListIssues(ctx *context.APIContext) {
}
func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 {
- userName := ctx.Query(queryName)
+ userName := ctx.Form(queryName)
if len(userName) == 0 {
return 0
}
diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go
index ad774b563b..eaf2c44c7c 100644
--- a/routers/api/v1/repo/issue_tracked_time.go
+++ b/routers/api/v1/repo/issue_tracked_time.go
@@ -90,7 +90,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
IssueID: issue.ID,
}
- qUser := strings.Trim(ctx.Query("user"), " ")
+ qUser := strings.Trim(ctx.Form("user"), " ")
if qUser != "" {
user, err := models.GetUserByName(qUser)
if models.IsErrUserNotExist(err) {
@@ -500,7 +500,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
}
// Filters
- qUser := strings.Trim(ctx.Query("user"), " ")
+ qUser := strings.Trim(ctx.Form("user"), " ")
if qUser != "" {
user, err := models.GetUserByName(qUser)
if models.IsErrUserNotExist(err) {
diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go
index b1b465ca11..d41531dd58 100644
--- a/routers/api/v1/repo/key.go
+++ b/routers/api/v1/repo/key.go
@@ -78,8 +78,8 @@ func ListDeployKeys(ctx *context.APIContext) {
var keys []*models.DeployKey
var err error
- fingerprint := ctx.Query("fingerprint")
- keyID := ctx.QueryInt64("key_id")
+ fingerprint := ctx.Form("fingerprint")
+ keyID := ctx.FormInt64("key_id")
if fingerprint != "" || keyID != 0 {
keys, err = models.SearchDeployKeys(ctx.Repo.Repository.ID, keyID, fingerprint)
} else {
diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go
index f71683f6ec..0d1368d18c 100644
--- a/routers/api/v1/repo/label.go
+++ b/routers/api/v1/repo/label.go
@@ -49,7 +49,7 @@ func ListLabels(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/LabelList"
- labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"), utils.GetListOptions(ctx))
+ labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Form("sort"), utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByRepoID", err)
return
diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go
index fc8b4efdbb..1231c3eb21 100644
--- a/routers/api/v1/repo/milestone.go
+++ b/routers/api/v1/repo/milestone.go
@@ -60,8 +60,8 @@ func ListMilestones(ctx *context.APIContext) {
milestones, err := models.GetMilestones(models.GetMilestonesOption{
ListOptions: utils.GetListOptions(ctx),
RepoID: ctx.Repo.Repository.ID,
- State: api.StateType(ctx.Query("state")),
- Name: ctx.Query("name"),
+ State: api.StateType(ctx.Form("state")),
+ Name: ctx.Form("name"),
})
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetMilestones", err)
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index de166d7ecb..ba47c3eb8e 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -86,10 +86,10 @@ func ListPullRequests(ctx *context.APIContext) {
prs, maxResults, err := models.PullRequests(ctx.Repo.Repository.ID, &models.PullRequestsOptions{
ListOptions: listOptions,
- State: ctx.QueryTrim("state"),
- SortType: ctx.QueryTrim("sort"),
- Labels: ctx.QueryStrings("labels"),
- MilestoneID: ctx.QueryInt64("milestone"),
+ State: ctx.FormTrim("state"),
+ SortType: ctx.FormTrim("sort"),
+ Labels: ctx.FormStrings("labels"),
+ MilestoneID: ctx.FormInt64("milestone"),
})
if err != nil {
diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go
index 1b52de55ff..97b90079f2 100644
--- a/routers/api/v1/repo/release.go
+++ b/routers/api/v1/repo/release.go
@@ -109,16 +109,16 @@ func ListReleases(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/ReleaseList"
listOptions := utils.GetListOptions(ctx)
- if listOptions.PageSize == 0 && ctx.QueryInt("per_page") != 0 {
- listOptions.PageSize = ctx.QueryInt("per_page")
+ if listOptions.PageSize == 0 && ctx.FormInt("per_page") != 0 {
+ listOptions.PageSize = ctx.FormInt("per_page")
}
opts := models.FindReleasesOptions{
ListOptions: listOptions,
IncludeDrafts: ctx.Repo.AccessMode >= models.AccessModeWrite,
IncludeTags: false,
- IsDraft: ctx.QueryOptionalBool("draft"),
- IsPreRelease: ctx.QueryOptionalBool("pre-release"),
+ IsDraft: ctx.FormOptionalBool("draft"),
+ IsPreRelease: ctx.FormOptionalBool("pre-release"),
}
releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts)
diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go
index 0a6425cddc..7986c47e6f 100644
--- a/routers/api/v1/repo/release_attachment.go
+++ b/routers/api/v1/repo/release_attachment.go
@@ -190,7 +190,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) {
}
var filename = header.Filename
- if query := ctx.Query("name"); query != "" {
+ if query := ctx.Form("name"); query != "" {
filename = query
}
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 5e0228fdbe..9c93408832 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -135,27 +135,27 @@ func Search(ctx *context.APIContext) {
opts := &models.SearchRepoOptions{
ListOptions: utils.GetListOptions(ctx),
Actor: ctx.User,
- Keyword: strings.Trim(ctx.Query("q"), " "),
- OwnerID: ctx.QueryInt64("uid"),
- PriorityOwnerID: ctx.QueryInt64("priority_owner_id"),
- TeamID: ctx.QueryInt64("team_id"),
- TopicOnly: ctx.QueryBool("topic"),
+ Keyword: strings.Trim(ctx.Form("q"), " "),
+ OwnerID: ctx.FormInt64("uid"),
+ PriorityOwnerID: ctx.FormInt64("priority_owner_id"),
+ TeamID: ctx.FormInt64("team_id"),
+ TopicOnly: ctx.FormBool("topic"),
Collaborate: util.OptionalBoolNone,
- Private: ctx.IsSigned && (ctx.Query("private") == "" || ctx.QueryBool("private")),
+ Private: ctx.IsSigned && (ctx.Form("private") == "" || ctx.FormBool("private")),
Template: util.OptionalBoolNone,
- StarredByID: ctx.QueryInt64("starredBy"),
- IncludeDescription: ctx.QueryBool("includeDesc"),
+ StarredByID: ctx.FormInt64("starredBy"),
+ IncludeDescription: ctx.FormBool("includeDesc"),
}
- if ctx.Query("template") != "" {
- opts.Template = util.OptionalBoolOf(ctx.QueryBool("template"))
+ if ctx.Form("template") != "" {
+ opts.Template = util.OptionalBoolOf(ctx.FormBool("template"))
}
- if ctx.QueryBool("exclusive") {
+ if ctx.FormBool("exclusive") {
opts.Collaborate = util.OptionalBoolFalse
}
- var mode = ctx.Query("mode")
+ var mode = ctx.Form("mode")
switch mode {
case "source":
opts.Fork = util.OptionalBoolFalse
@@ -173,17 +173,17 @@ func Search(ctx *context.APIContext) {
return
}
- if ctx.Query("archived") != "" {
- opts.Archived = util.OptionalBoolOf(ctx.QueryBool("archived"))
+ if ctx.Form("archived") != "" {
+ opts.Archived = util.OptionalBoolOf(ctx.FormBool("archived"))
}
- if ctx.Query("is_private") != "" {
- opts.IsPrivate = util.OptionalBoolOf(ctx.QueryBool("is_private"))
+ if ctx.Form("is_private") != "" {
+ opts.IsPrivate = util.OptionalBoolOf(ctx.FormBool("is_private"))
}
- var sortMode = ctx.Query("sort")
+ var sortMode = ctx.Form("sort")
if len(sortMode) > 0 {
- var sortOrder = ctx.Query("order")
+ var sortOrder = ctx.Form("order")
if len(sortOrder) == 0 {
sortOrder = "asc"
}
diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go
index 95c3f00a72..841f60bb56 100644
--- a/routers/api/v1/repo/status.go
+++ b/routers/api/v1/repo/status.go
@@ -190,11 +190,11 @@ func getCommitStatuses(ctx *context.APIContext, sha string) {
statuses, maxResults, err := models.GetCommitStatuses(repo, sha, &models.CommitStatusOptions{
ListOptions: listOptions,
- SortType: ctx.QueryTrim("sort"),
- State: ctx.QueryTrim("state"),
+ SortType: ctx.FormTrim("sort"),
+ State: ctx.FormTrim("state"),
})
if err != nil {
- ctx.Error(http.StatusInternalServerError, "GetCommitStatuses", fmt.Errorf("GetCommitStatuses[%s, %s, %d]: %v", repo.FullName(), sha, ctx.QueryInt("page"), err))
+ ctx.Error(http.StatusInternalServerError, "GetCommitStatuses", fmt.Errorf("GetCommitStatuses[%s, %s, %d]: %v", repo.FullName(), sha, ctx.FormInt("page"), err))
return
}
diff --git a/routers/api/v1/repo/topic.go b/routers/api/v1/repo/topic.go
index c612c2942c..14712f536f 100644
--- a/routers/api/v1/repo/topic.go
+++ b/routers/api/v1/repo/topic.go
@@ -274,7 +274,7 @@ func TopicSearch(ctx *context.APIContext) {
return
}
- kw := ctx.Query("q")
+ kw := ctx.Form("q")
listOptions := utils.GetListOptions(ctx)
diff --git a/routers/api/v1/repo/tree.go b/routers/api/v1/repo/tree.go
index e6c57af3e2..aec336235d 100644
--- a/routers/api/v1/repo/tree.go
+++ b/routers/api/v1/repo/tree.go
@@ -60,7 +60,7 @@ func GetTree(ctx *context.APIContext) {
ctx.Error(http.StatusBadRequest, "", "sha not provided")
return
}
- if tree, err := repofiles.GetTreeBySHA(ctx.Repo.Repository, sha, ctx.QueryInt("page"), ctx.QueryInt("per_page"), ctx.QueryBool("recursive")); err != nil {
+ if tree, err := repofiles.GetTreeBySHA(ctx.Repo.Repository, sha, ctx.FormInt("page"), ctx.FormInt("per_page"), ctx.FormBool("recursive")); err != nil {
ctx.Error(http.StatusBadRequest, "", err.Error())
} else {
ctx.JSON(http.StatusOK, tree)
diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go
index 780cdf417c..284653b108 100644
--- a/routers/api/v1/user/key.go
+++ b/routers/api/v1/user/key.go
@@ -48,7 +48,7 @@ func listPublicKeys(ctx *context.APIContext, user *models.User) {
var keys []*models.PublicKey
var err error
- fingerprint := ctx.Query("fingerprint")
+ fingerprint := ctx.Form("fingerprint")
username := ctx.Params("username")
if fingerprint != "" {
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go
index ac543d597d..de1fd5a5c5 100644
--- a/routers/api/v1/user/user.go
+++ b/routers/api/v1/user/user.go
@@ -58,8 +58,8 @@ func Search(ctx *context.APIContext) {
opts := &models.SearchUserOptions{
Actor: ctx.User,
- Keyword: strings.Trim(ctx.Query("q"), " "),
- UID: ctx.QueryInt64("uid"),
+ Keyword: strings.Trim(ctx.Form("q"), " "),
+ UID: ctx.FormInt64("uid"),
Type: models.UserTypeIndividual,
ListOptions: listOptions,
}
diff --git a/routers/api/v1/utils/utils.go b/routers/api/v1/utils/utils.go
index 10ab3ebd0c..ee70723bd1 100644
--- a/routers/api/v1/utils/utils.go
+++ b/routers/api/v1/utils/utils.go
@@ -54,7 +54,7 @@ func parseTime(value string) (int64, error) {
// prepareQueryArg unescape and trim a query arg
func prepareQueryArg(ctx *context.APIContext, name string) (value string, err error) {
- value, err = url.PathUnescape(ctx.Query(name))
+ value, err = url.PathUnescape(ctx.Form(name))
value = strings.TrimSpace(value)
return
}
@@ -62,7 +62,7 @@ func prepareQueryArg(ctx *context.APIContext, name string) (value string, err er
// GetListOptions returns list options using the page and limit parameters
func GetListOptions(ctx *context.APIContext) models.ListOptions {
return models.ListOptions{
- Page: ctx.QueryInt("page"),
- PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
+ Page: ctx.FormInt("page"),
+ PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")),
}
}