Skip to content

Commit 8e54c8f

Browse files
authored
🐛 fix: Update binder in form_test (#3336)
* Fix: error binder in form_test * fix: form tag * Fix: error package name
1 parent 9e6f4fd commit 8e54c8f

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

binder/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Fiber provides several default binders out of the box:
2828

2929
### Binding into a Struct
3030

31-
Fiber supports binding request data directly into a struct using [gorilla/schema](https://github.com/gorilla/schema). Here's an example:
31+
Fiber supports binding request data directly into a struct using [gofiber/schema](https://github.com/gofiber/schema). Here's an example:
3232

3333
```go
3434
// Field names must start with an uppercase letter

binder/form_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,19 @@ func Benchmark_FormBinder_Bind(b *testing.B) {
5858
b.ReportAllocs()
5959
b.ResetTimer()
6060

61-
binder := &QueryBinding{
61+
binder := &FormBinding{
6262
EnableSplitting: true,
6363
}
6464

6565
type User struct {
66-
Name string `query:"name"`
67-
Posts []string `query:"posts"`
68-
Age int `query:"age"`
66+
Name string `form:"name"`
67+
Posts []string `form:"posts"`
68+
Age int `form:"age"`
6969
}
7070
var user User
7171

7272
req := fasthttp.AcquireRequest()
73-
req.URI().SetQueryString("name=john&age=42&posts=post1,post2,post3")
73+
req.SetBodyString("name=john&age=42&posts=post1,post2,post3")
7474
req.Header.SetContentType("application/x-www-form-urlencoded")
7575

7676
b.ResetTimer()

binder/mapping.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func parse(aliasTag string, out any, data map[string][]string, files ...map[stri
8787
return parseToStruct(aliasTag, out, data, files...)
8888
}
8989

90-
// Parse data into the struct with gorilla/schema
90+
// Parse data into the struct with gofiber/schema
9191
func parseToStruct(aliasTag string, out any, data map[string][]string, files ...map[string][]*multipart.FileHeader) error {
9292
// Get decoder from pool
9393
schemaDecoder := decoderPoolMap[aliasTag].Get().(*schema.Decoder) //nolint:errcheck,forcetypeassert // not needed

error.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var (
4040
ErrNoHandlers = errors.New("format: at least one handler is required, but none were set")
4141
)
4242

43-
// gorilla/schema errors
43+
// gofiber/schema errors
4444
type (
4545
// ConversionError Conversion error exposes the internal schema.ConversionError for public use.
4646
ConversionError = schema.ConversionError

0 commit comments

Comments
 (0)