mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-06 10:23:55 +00:00
♻️ refactor: rename methods
This commit is contained in:
parent
c2b557c5ac
commit
69e5ccdd22
@ -608,7 +608,7 @@ func setConfigToRequest(req *Request, config ...Config) {
|
||||
}
|
||||
|
||||
if cfg.FormData != nil {
|
||||
req.SetFormDatas(cfg.FormData)
|
||||
req.SetFormDataWithMap(cfg.FormData)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ func Test_Parser_Request_Header(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := New()
|
||||
req := AcquireRequest().
|
||||
SetFormDatas(map[string]string{
|
||||
SetFormDataWithMap(map[string]string{
|
||||
"foo": "bar",
|
||||
"ball": "cricle and square",
|
||||
})
|
||||
@ -485,7 +485,7 @@ func Test_Parser_Request_Body(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := New()
|
||||
req := AcquireRequest().
|
||||
SetFormDatas(map[string]string{
|
||||
SetFormDataWithMap(map[string]string{
|
||||
"ball": "cricle and square",
|
||||
})
|
||||
|
||||
@ -498,7 +498,7 @@ func Test_Parser_Request_Body(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := New()
|
||||
req := AcquireRequest().
|
||||
SetFormDatas(map[string]string{
|
||||
SetFormDataWithMap(map[string]string{
|
||||
"": "",
|
||||
})
|
||||
|
||||
|
@ -460,42 +460,42 @@ func (r *Request) AllFormData() iter.Seq2[string, []string] {
|
||||
|
||||
// AddFormData adds a single form field and value to the Request.
|
||||
func (r *Request) AddFormData(key, val string) *Request {
|
||||
r.formData.AddData(key, val)
|
||||
r.formData.Add(key, val)
|
||||
r.resetBody(formBody)
|
||||
return r
|
||||
}
|
||||
|
||||
// SetFormData sets a single form field and value, overriding any previously set value.
|
||||
func (r *Request) SetFormData(key, val string) *Request {
|
||||
r.formData.SetData(key, val)
|
||||
r.formData.Set(key, val)
|
||||
r.resetBody(formBody)
|
||||
return r
|
||||
}
|
||||
|
||||
// AddFormDatas adds multiple form fields and values to the Request.
|
||||
func (r *Request) AddFormDatas(m map[string][]string) *Request {
|
||||
r.formData.AddDatas(m)
|
||||
// AddFormDataWithMap adds multiple form fields and values to the Request.
|
||||
func (r *Request) AddFormDataWithMap(m map[string][]string) *Request {
|
||||
r.formData.AddWithMap(m)
|
||||
r.resetBody(formBody)
|
||||
return r
|
||||
}
|
||||
|
||||
// SetFormDatas sets multiple form fields and values at once, overriding previously set values.
|
||||
func (r *Request) SetFormDatas(m map[string]string) *Request {
|
||||
r.formData.SetDatas(m)
|
||||
// SetFormDataWithMap sets multiple form fields and values at once, overriding previously set values.
|
||||
func (r *Request) SetFormDataWithMap(m map[string]string) *Request {
|
||||
r.formData.SetWithMap(m)
|
||||
r.resetBody(formBody)
|
||||
return r
|
||||
}
|
||||
|
||||
// SetFormDatasWithStruct sets multiple form fields from a struct, overriding previously set values.
|
||||
func (r *Request) SetFormDatasWithStruct(v any) *Request {
|
||||
r.formData.SetDatasWithStruct(v)
|
||||
// SetFormDataWithStruct sets multiple form fields from a struct, overriding previously set values.
|
||||
func (r *Request) SetFormDataWithStruct(v any) *Request {
|
||||
r.formData.SetWithStruct(v)
|
||||
r.resetBody(formBody)
|
||||
return r
|
||||
}
|
||||
|
||||
// DelFormDatas deletes one or more form fields.
|
||||
func (r *Request) DelFormDatas(key ...string) *Request {
|
||||
r.formData.DelDatas(key...)
|
||||
// DelFormData deletes one or more form fields.
|
||||
func (r *Request) DelFormData(key ...string) *Request {
|
||||
r.formData.DelData(key...)
|
||||
r.resetBody(formBody)
|
||||
return r
|
||||
}
|
||||
@ -845,18 +845,18 @@ func (f *FormData) Keys() []string {
|
||||
return slices.Compact(keys)
|
||||
}
|
||||
|
||||
// AddData adds a single form field.
|
||||
func (f *FormData) AddData(key, val string) {
|
||||
f.Add(key, val)
|
||||
// Add adds a single form field.
|
||||
func (f *FormData) Add(key, val string) {
|
||||
f.Args.Add(key, val)
|
||||
}
|
||||
|
||||
// SetData sets a single form field, overriding previously set values.
|
||||
func (f *FormData) SetData(key, val string) {
|
||||
f.Set(key, val)
|
||||
// Set sets a single form field, overriding previously set values.
|
||||
func (f *FormData) Set(key, val string) {
|
||||
f.Args.Set(key, val)
|
||||
}
|
||||
|
||||
// AddDatas adds multiple form fields from a map.
|
||||
func (f *FormData) AddDatas(m map[string][]string) {
|
||||
// AddWithMap adds multiple form fields from a map.
|
||||
func (f *FormData) AddWithMap(m map[string][]string) {
|
||||
for k, v := range m {
|
||||
for _, vv := range v {
|
||||
f.Add(k, vv)
|
||||
@ -864,23 +864,23 @@ func (f *FormData) AddDatas(m map[string][]string) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetDatas sets multiple form fields from a map, overriding previously set values.
|
||||
func (f *FormData) SetDatas(m map[string]string) {
|
||||
// SetWithMap sets multiple form fields from a map, overriding previously set values.
|
||||
func (f *FormData) SetWithMap(m map[string]string) {
|
||||
for k, v := range m {
|
||||
f.Set(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
// SetDatasWithStruct sets multiple form fields from a struct.
|
||||
// SetWithStruct sets multiple form fields from a struct.
|
||||
// Nested structs are not currently supported.
|
||||
func (f *FormData) SetDatasWithStruct(v any) {
|
||||
func (f *FormData) SetWithStruct(v any) {
|
||||
SetValWithStruct(f, "form", v)
|
||||
}
|
||||
|
||||
// DelDatas deletes multiple form fields.
|
||||
func (f *FormData) DelDatas(key ...string) {
|
||||
// DelData deletes multiple form fields.
|
||||
func (f *FormData) DelData(key ...string) {
|
||||
for _, v := range key {
|
||||
f.Del(v)
|
||||
f.Args.Del(v)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -615,7 +615,7 @@ func Test_Request_FormData(t *testing.T) {
|
||||
req := AcquireRequest()
|
||||
defer ReleaseRequest(req)
|
||||
req.SetFormData("foo", "bar").
|
||||
AddFormDatas(map[string][]string{
|
||||
AddFormDataWithMap(map[string][]string{
|
||||
"foo": {"fiber", "buaa"},
|
||||
"bar": {"foo"},
|
||||
})
|
||||
@ -636,7 +636,7 @@ func Test_Request_FormData(t *testing.T) {
|
||||
req := AcquireRequest()
|
||||
defer ReleaseRequest(req)
|
||||
req.SetFormData("foo", "bar").
|
||||
SetFormDatas(map[string]string{
|
||||
SetFormDataWithMap(map[string]string{
|
||||
"foo": "fiber",
|
||||
"bar": "foo",
|
||||
})
|
||||
@ -664,7 +664,7 @@ func Test_Request_FormData(t *testing.T) {
|
||||
|
||||
p := AcquireRequest()
|
||||
defer ReleaseRequest(p)
|
||||
p.SetFormDatasWithStruct(&args{
|
||||
p.SetFormDataWithStruct(&args{
|
||||
TInt: 5,
|
||||
TString: "string",
|
||||
TFloat: 3.1,
|
||||
@ -702,10 +702,10 @@ func Test_Request_FormData(t *testing.T) {
|
||||
req := AcquireRequest()
|
||||
defer ReleaseRequest(req)
|
||||
req.SetFormData("foo", "bar").
|
||||
SetFormDatas(map[string]string{
|
||||
SetFormDataWithMap(map[string]string{
|
||||
"foo": "fiber",
|
||||
"bar": "foo",
|
||||
}).DelFormDatas("foo", "bar")
|
||||
}).DelFormData("foo", "bar")
|
||||
|
||||
res := req.FormData("foo")
|
||||
require.Empty(t, res)
|
||||
@ -1212,7 +1212,7 @@ func Test_Request_Body_With_Server(t *testing.T) {
|
||||
},
|
||||
func(agent *Request) {
|
||||
agent.SetFormData("foo", "bar").
|
||||
SetFormDatas(map[string]string{
|
||||
SetFormDataWithMap(map[string]string{
|
||||
"bar": "baz",
|
||||
"fiber": "fast",
|
||||
})
|
||||
@ -1362,7 +1362,7 @@ func Test_Request_AllFormData(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
req := AcquireRequest()
|
||||
req.AddFormDatas(map[string][]string{
|
||||
req.AddFormDataWithMap(map[string][]string{
|
||||
"foo": {"bar", "fiber"},
|
||||
"bar": {"foo"},
|
||||
})
|
||||
@ -1378,7 +1378,7 @@ func Test_Request_AllFormData(t *testing.T) {
|
||||
|
||||
func Benchmark_Request_AllFormData(b *testing.B) {
|
||||
req := AcquireRequest()
|
||||
req.AddFormDatas(map[string][]string{
|
||||
req.AddFormDataWithMap(map[string][]string{
|
||||
"foo": {"bar", "fiber"},
|
||||
"bar": {"foo"},
|
||||
})
|
||||
|
@ -825,36 +825,36 @@ fmt.Println(string(resp.Body()))
|
||||
|
||||
</details>
|
||||
|
||||
### AddFormDatas
|
||||
### AddFormDataWithMap
|
||||
|
||||
**AddFormDatas** adds multiple form data fields and values from a map of string slices.
|
||||
**AddFormDataWithMap** adds multiple form data fields and values from a map of string slices.
|
||||
|
||||
```go title="Signature"
|
||||
func (r *Request) AddFormDatas(m map[string][]string) *Request
|
||||
func (r *Request) AddFormDataWithMap(m map[string][]string) *Request
|
||||
```
|
||||
|
||||
### SetFormDatas
|
||||
### SetFormDataWithMap
|
||||
|
||||
**SetFormDatas** sets multiple form data fields from a map of strings.
|
||||
**SetFormDataWithMap** sets multiple form data fields from a map of strings.
|
||||
|
||||
```go title="Signature"
|
||||
func (r *Request) SetFormDatas(m map[string]string) *Request
|
||||
func (r *Request) SetFormDataWithMap(m map[string]string) *Request
|
||||
```
|
||||
|
||||
### SetFormDatasWithStruct
|
||||
### SetFormDataWithStruct
|
||||
|
||||
**SetFormDatasWithStruct** sets multiple form data fields from a struct.
|
||||
**SetFormDataWithStruct** sets multiple form data fields from a struct.
|
||||
|
||||
```go title="Signature"
|
||||
func (r *Request) SetFormDatasWithStruct(v any) *Request
|
||||
func (r *Request) SetFormDataWithStruct(v any) *Request
|
||||
```
|
||||
|
||||
### DelFormDatas
|
||||
### DelFormData
|
||||
|
||||
**DelFormDatas** deletes one or more form data fields by their keys.
|
||||
**DelFormData** deletes one or more form data fields by their keys.
|
||||
|
||||
```go title="Signature"
|
||||
func (r *Request) DelFormDatas(key ...string) *Request
|
||||
func (r *Request) DelFormData(key ...string) *Request
|
||||
```
|
||||
|
||||
## File
|
||||
@ -1311,52 +1311,52 @@ type FormData struct {
|
||||
func (f *FormData) Keys() []string
|
||||
```
|
||||
|
||||
### AddData
|
||||
### Add
|
||||
|
||||
**AddData** adds a single form field key-value pair.
|
||||
**Add** adds a single form field key-value pair.
|
||||
|
||||
```go title="Signature"
|
||||
func (f *FormData) AddData(key, val string)
|
||||
func (f *FormData) Add(key, val string)
|
||||
```
|
||||
|
||||
### SetData
|
||||
### Set
|
||||
|
||||
**SetData** sets a single form field key-value pair, overriding any previously set values.
|
||||
**Set** sets a single form field key-value pair, overriding any previously set values.
|
||||
|
||||
```go title="Signature"
|
||||
func (f *FormData) SetData(key, val string)
|
||||
func (f *FormData) Set(key, val string)
|
||||
```
|
||||
|
||||
### AddDatas
|
||||
### AddWithMap
|
||||
|
||||
**AddDatas** adds multiple form fields from a map of string slices.
|
||||
**AddWithMap** adds multiple form fields from a map of string slices.
|
||||
|
||||
```go title="Signature"
|
||||
func (f *FormData) AddDatas(m map[string][]string)
|
||||
func (f *FormData) AddWithMap(m map[string][]string)
|
||||
```
|
||||
|
||||
### SetDatas
|
||||
### SetWithMap
|
||||
|
||||
**SetDatas** sets multiple form fields from a map of strings.
|
||||
**SetWithMap** sets multiple form fields from a map of strings.
|
||||
|
||||
```go title="Signature"
|
||||
func (f *FormData) SetDatas(m map[string]string)
|
||||
func (f *FormData) SetWithMap(m map[string]string)
|
||||
```
|
||||
|
||||
### SetDatasWithStruct
|
||||
### SetWithStruct
|
||||
|
||||
**SetDatasWithStruct** sets multiple form fields from a struct.
|
||||
**SetWithStruct** sets multiple form fields from a struct.
|
||||
|
||||
```go title="Signature"
|
||||
func (f *FormData) SetDatasWithStruct(v any)
|
||||
func (f *FormData) SetWithStruct(v any)
|
||||
```
|
||||
|
||||
### DelDatas
|
||||
### DelData
|
||||
|
||||
**DelDatas** deletes one or more form fields by their keys.
|
||||
**DelData** deletes one or more form fields by their keys.
|
||||
|
||||
```go title="Signature"
|
||||
func (f *FormData) DelDatas(key ...string)
|
||||
func (f *FormData) DelData(key ...string)
|
||||
```
|
||||
|
||||
### Reset
|
||||
|
Loading…
x
Reference in New Issue
Block a user