Skip to content

Commit 924fa81

Browse files
committed
Merge
1 parent e59b1b9 commit 924fa81

File tree

2 files changed

+7
-43
lines changed

2 files changed

+7
-43
lines changed

modules/context/base.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
"code.gitea.io/gitea/modules/json"
1616
"code.gitea.io/gitea/modules/log"
17-
"code.gitea.io/gitea/modules/util"
1817

1918
chi "github.com/go-chi/chi/v5"
2019
)
@@ -109,41 +108,6 @@ func (ctx *BaseContext) Value(key interface{}) interface{} {
109108
return ctx.Req.Context().Value(key)
110109
}
111110

112-
// Form returns request form as string with default
113-
func (ctx *BaseContext) Form(key string, defaults ...string) string {
114-
return (*Forms)(ctx.Req).MustString(key, defaults...)
115-
}
116-
117-
// FormTrim returns request form as string with default and trimmed spaces
118-
func (ctx *BaseContext) FormTrim(key string, defaults ...string) string {
119-
return (*Forms)(ctx.Req).MustTrimmed(key, defaults...)
120-
}
121-
122-
// FormStrings returns request form as strings with default
123-
func (ctx *BaseContext) FormStrings(key string, defaults ...[]string) []string {
124-
return (*Forms)(ctx.Req).MustStrings(key, defaults...)
125-
}
126-
127-
// FormInt returns request form as int with default
128-
func (ctx *BaseContext) FormInt(key string, defaults ...int) int {
129-
return (*Forms)(ctx.Req).MustInt(key, defaults...)
130-
}
131-
132-
// FormInt64 returns request form as int64 with default
133-
func (ctx *BaseContext) FormInt64(key string, defaults ...int64) int64 {
134-
return (*Forms)(ctx.Req).MustInt64(key, defaults...)
135-
}
136-
137-
// FormBool returns request form as bool with default
138-
func (ctx *BaseContext) FormBool(key string, defaults ...bool) bool {
139-
return (*Forms)(ctx.Req).MustBool(key, defaults...)
140-
}
141-
142-
// FormOptionalBool returns request form as OptionalBool with default
143-
func (ctx *BaseContext) FormOptionalBool(key string, defaults ...util.OptionalBool) util.OptionalBool {
144-
return (*Forms)(ctx.Req).MustOptionalBool(key, defaults...)
145-
}
146-
147111
// Error returned an error to web browser
148112
func (ctx *BaseContext) Error(status int, contents ...string) {
149113
var v = http.StatusText(status)

modules/context/form.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import (
1212
)
1313

1414
// FormString returns the first value matching the provided key in the form as a string
15-
func (ctx *Context) FormString(key string) string {
15+
func (ctx *BaseContext) FormString(key string) string {
1616
return ctx.Req.FormValue(key)
1717
}
1818

1919
// FormStrings returns a string slice for the provided key from the form
20-
func (ctx *Context) FormStrings(key string) []string {
20+
func (ctx *BaseContext) FormStrings(key string) []string {
2121
if ctx.Req.Form == nil {
2222
if err := ctx.Req.ParseMultipartForm(32 << 20); err != nil {
2323
return nil
@@ -30,31 +30,31 @@ func (ctx *Context) FormStrings(key string) []string {
3030
}
3131

3232
// FormTrim returns the first value for the provided key in the form as a space trimmed string
33-
func (ctx *Context) FormTrim(key string) string {
33+
func (ctx *BaseContext) FormTrim(key string) string {
3434
return strings.TrimSpace(ctx.Req.FormValue(key))
3535
}
3636

3737
// FormInt returns the first value for the provided key in the form as an int
38-
func (ctx *Context) FormInt(key string) int {
38+
func (ctx *BaseContext) FormInt(key string) int {
3939
v, _ := strconv.Atoi(ctx.Req.FormValue(key))
4040
return v
4141
}
4242

4343
// FormInt64 returns the first value for the provided key in the form as an int64
44-
func (ctx *Context) FormInt64(key string) int64 {
44+
func (ctx *BaseContext) FormInt64(key string) int64 {
4545
v, _ := strconv.ParseInt(ctx.Req.FormValue(key), 10, 64)
4646
return v
4747
}
4848

4949
// FormBool returns true if the value for the provided key in the form is "1" or "true"
50-
func (ctx *Context) FormBool(key string) bool {
50+
func (ctx *BaseContext) FormBool(key string) bool {
5151
v, _ := strconv.ParseBool(ctx.Req.FormValue(key))
5252
return v
5353
}
5454

5555
// FormOptionalBool returns an OptionalBoolTrue or OptionalBoolFalse if the value
5656
// for the provided key exists in the form else it returns OptionalBoolNone
57-
func (ctx *Context) FormOptionalBool(key string) util.OptionalBool {
57+
func (ctx *BaseContext) FormOptionalBool(key string) util.OptionalBool {
5858
value := ctx.Req.FormValue(key)
5959
if len(value) == 0 {
6060
return util.OptionalBoolNone

0 commit comments

Comments
 (0)