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
|
@ -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, ","))
|
||||
|
|
|
@ -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...)
|
||||
}
|
||||
|
||||
|
|
|
@ -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}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue