forked from forgejo/forgejo
Rename context.Query to context.Form (#16562)
This commit is contained in:
parent
3705168837
commit
33e0b38287
85 changed files with 393 additions and 396 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ func TopicSearch(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
kw := ctx.Query("q")
|
||||
kw := ctx.Form("q")
|
||||
|
||||
listOptions := utils.GetListOptions(ctx)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 != "" {
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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")),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue