mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 05:52:43 +00:00
Rename ctx.Form() to ctx.FormString() and move code into own file (#16571)
Followup from #16562 prepare for #16567 * Rename ctx.Form() to ctx.FormString() * Reimplement FormX func to need less code and cpu cycles * Move code into own file
This commit is contained in:
parent
2eeae4edb6
commit
c4d70a0325
64 changed files with 236 additions and 449 deletions
|
@ -106,7 +106,7 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
var isClosed util.OptionalBool
|
||||
switch ctx.Form("state") {
|
||||
switch ctx.FormString("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.Form("q"), " ")
|
||||
keyword := strings.Trim(ctx.FormString("q"), " ")
|
||||
if strings.IndexByte(keyword, 0) >= 0 {
|
||||
keyword = ""
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
var isPull util.OptionalBool
|
||||
switch ctx.Form("type") {
|
||||
switch ctx.FormString("type") {
|
||||
case "pulls":
|
||||
isPull = util.OptionalBoolTrue
|
||||
case "issues":
|
||||
|
@ -162,13 +162,13 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
isPull = util.OptionalBoolNone
|
||||
}
|
||||
|
||||
labels := strings.TrimSpace(ctx.Form("labels"))
|
||||
labels := strings.TrimSpace(ctx.FormString("labels"))
|
||||
var includedLabelNames []string
|
||||
if len(labels) > 0 {
|
||||
includedLabelNames = strings.Split(labels, ",")
|
||||
}
|
||||
|
||||
milestones := strings.TrimSpace(ctx.Form("milestones"))
|
||||
milestones := strings.TrimSpace(ctx.FormString("milestones"))
|
||||
var includedMilestones []string
|
||||
if len(milestones) > 0 {
|
||||
includedMilestones = strings.Split(milestones, ",")
|
||||
|
@ -319,7 +319,7 @@ func ListIssues(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
var isClosed util.OptionalBool
|
||||
switch ctx.Form("state") {
|
||||
switch ctx.FormString("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.Form("q"), " ")
|
||||
keyword := strings.Trim(ctx.FormString("q"), " ")
|
||||
if strings.IndexByte(keyword, 0) >= 0 {
|
||||
keyword = ""
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ func ListIssues(ctx *context.APIContext) {
|
|||
}
|
||||
}
|
||||
|
||||
if splitted := strings.Split(ctx.Form("labels"), ","); len(splitted) > 0 {
|
||||
if splitted := strings.Split(ctx.FormString("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.Form("milestones"), ","); len(part) > 0 {
|
||||
if part := strings.Split(ctx.FormString("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.Form("type") {
|
||||
switch ctx.FormString("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.Form(queryName)
|
||||
userName := ctx.FormString(queryName)
|
||||
if len(userName) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue