summaryrefslogtreecommitdiffstats
path: root/modules/context
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 /modules/context
parent370516883717de0e6e2087c12d368eb1465ee3b0 (diff)
downloadgitea-33e0b38287fdc3487112062300b8dd3c95415ee7.tar.gz
gitea-33e0b38287fdc3487112062300b8dd3c95415ee7.zip
Rename context.Query to context.Form (#16562)
Diffstat (limited to 'modules/context')
-rw-r--r--modules/context/api.go2
-rw-r--r--modules/context/context.go31
-rw-r--r--modules/context/repo.go8
3 files changed, 19 insertions, 22 deletions
diff --git a/modules/context/api.go b/modules/context/api.go
index 78d48e9169..a21e0d7402 100644
--- a/modules/context/api.go
+++ b/modules/context/api.go
@@ -177,7 +177,7 @@ func genAPILinks(curURL *url.URL, total, pageSize, curPage int) []string {
// SetLinkHeader sets pagination link header by given total number and page size.
func (ctx *APIContext) SetLinkHeader(total, pageSize int) {
- links := genAPILinks(ctx.Req.URL, total, pageSize, ctx.QueryInt("page"))
+ links := genAPILinks(ctx.Req.URL, total, pageSize, ctx.FormInt("page"))
if len(links) > 0 {
ctx.Header().Set("Link", strings.Join(links, ","))
diff --git a/modules/context/context.go b/modules/context/context.go
index 6973f0dddc..b356e1eb1b 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -287,41 +287,38 @@ func (ctx *Context) Header() http.Header {
return ctx.Resp.Header()
}
-// FIXME: We should differ Query and Form, currently we just use form as query
-// Currently to be compatible with macaron, we keep it.
-
-// Query returns request form as string with default
-func (ctx *Context) Query(key string, defaults ...string) string {
+// Form returns request form as string with default
+func (ctx *Context) Form(key string, defaults ...string) string {
return (*Forms)(ctx.Req).MustString(key, defaults...)
}
-// QueryTrim returns request form as string with default and trimmed spaces
-func (ctx *Context) QueryTrim(key string, defaults ...string) string {
+// FormTrim returns request form as string with default and trimmed spaces
+func (ctx *Context) FormTrim(key string, defaults ...string) string {
return (*Forms)(ctx.Req).MustTrimmed(key, defaults...)
}
-// QueryStrings returns request form as strings with default
-func (ctx *Context) QueryStrings(key string, defaults ...[]string) []string {
+// FormStrings returns request form as strings with default
+func (ctx *Context) FormStrings(key string, defaults ...[]string) []string {
return (*Forms)(ctx.Req).MustStrings(key, defaults...)
}
-// QueryInt returns request form as int with default
-func (ctx *Context) QueryInt(key string, defaults ...int) int {
+// FormInt returns request form as int with default
+func (ctx *Context) FormInt(key string, defaults ...int) int {
return (*Forms)(ctx.Req).MustInt(key, defaults...)
}
-// QueryInt64 returns request form as int64 with default
-func (ctx *Context) QueryInt64(key string, defaults ...int64) int64 {
+// FormInt64 returns request form as int64 with default
+func (ctx *Context) FormInt64(key string, defaults ...int64) int64 {
return (*Forms)(ctx.Req).MustInt64(key, defaults...)
}
-// QueryBool returns request form as bool with default
-func (ctx *Context) QueryBool(key string, defaults ...bool) bool {
+// FormBool returns request form as bool with default
+func (ctx *Context) FormBool(key string, defaults ...bool) bool {
return (*Forms)(ctx.Req).MustBool(key, defaults...)
}
-// QueryOptionalBool returns request form as OptionalBool with default
-func (ctx *Context) QueryOptionalBool(key string, defaults ...util.OptionalBool) util.OptionalBool {
+// FormOptionalBool returns request form as OptionalBool with default
+func (ctx *Context) FormOptionalBool(key string, defaults ...util.OptionalBool) util.OptionalBool {
return (*Forms)(ctx.Req).MustOptionalBool(key, defaults...)
}
diff --git a/modules/context/repo.go b/modules/context/repo.go
index ea8323bdfc..abd9ca5481 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -346,7 +346,7 @@ func repoAssignment(ctx *Context, repo *models.Repository) {
// Check access.
if ctx.Repo.Permission.AccessMode == models.AccessModeNone {
- if ctx.Query("go-get") == "1" {
+ if ctx.Form("go-get") == "1" {
EarlyResponseForGoGetMeta(ctx)
return
}
@@ -415,7 +415,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
owner, err = models.GetUserByName(userName)
if err != nil {
if models.IsErrUserNotExist(err) {
- if ctx.Query("go-get") == "1" {
+ if ctx.Form("go-get") == "1" {
EarlyResponseForGoGetMeta(ctx)
return
}
@@ -437,7 +437,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
if err == nil {
RedirectToRepo(ctx, redirectRepoID)
} else if models.IsErrRepoRedirectNotExist(err) {
- if ctx.Query("go-get") == "1" {
+ if ctx.Form("go-get") == "1" {
EarlyResponseForGoGetMeta(ctx)
return
}
@@ -618,7 +618,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
}
}
- if ctx.Query("go-get") == "1" {
+ if ctx.Form("go-get") == "1" {
ctx.Data["GoGetImport"] = ComposeGoGetImport(owner.Name, repo.Name)
prefix := setting.AppURL + path.Join(owner.Name, repo.Name, "src", "branch", ctx.Repo.BranchName)
ctx.Data["GoDocDirectory"] = prefix + "{/dir}"