From 8e54c8f93809c4257b03548c16cffb8134fb5e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Tue, 4 Mar 2025 12:46:05 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Update=20binder=20in=20fo?= =?UTF-8?q?rm=5Ftest=20(#3336)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix: error binder in form_test * fix: form tag * Fix: error package name --- binder/README.md | 2 +- binder/form_test.go | 10 +++++----- binder/mapping.go | 2 +- error.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/binder/README.md b/binder/README.md index 4d75fd1b..aded1efa 100644 --- a/binder/README.md +++ b/binder/README.md @@ -28,7 +28,7 @@ Fiber provides several default binders out of the box: ### Binding into a Struct -Fiber supports binding request data directly into a struct using [gorilla/schema](https://github.com/gorilla/schema). Here's an example: +Fiber supports binding request data directly into a struct using [gofiber/schema](https://github.com/gofiber/schema). Here's an example: ```go // Field names must start with an uppercase letter diff --git a/binder/form_test.go b/binder/form_test.go index d961f873..ac421d82 100644 --- a/binder/form_test.go +++ b/binder/form_test.go @@ -58,19 +58,19 @@ func Benchmark_FormBinder_Bind(b *testing.B) { b.ReportAllocs() b.ResetTimer() - binder := &QueryBinding{ + binder := &FormBinding{ EnableSplitting: true, } type User struct { - Name string `query:"name"` - Posts []string `query:"posts"` - Age int `query:"age"` + Name string `form:"name"` + Posts []string `form:"posts"` + Age int `form:"age"` } var user User req := fasthttp.AcquireRequest() - req.URI().SetQueryString("name=john&age=42&posts=post1,post2,post3") + req.SetBodyString("name=john&age=42&posts=post1,post2,post3") req.Header.SetContentType("application/x-www-form-urlencoded") b.ResetTimer() diff --git a/binder/mapping.go b/binder/mapping.go index bc95d028..41026a16 100644 --- a/binder/mapping.go +++ b/binder/mapping.go @@ -87,7 +87,7 @@ func parse(aliasTag string, out any, data map[string][]string, files ...map[stri return parseToStruct(aliasTag, out, data, files...) } -// Parse data into the struct with gorilla/schema +// Parse data into the struct with gofiber/schema func parseToStruct(aliasTag string, out any, data map[string][]string, files ...map[string][]*multipart.FileHeader) error { // Get decoder from pool schemaDecoder := decoderPoolMap[aliasTag].Get().(*schema.Decoder) //nolint:errcheck,forcetypeassert // not needed diff --git a/error.go b/error.go index f0375657..8d0ca635 100644 --- a/error.go +++ b/error.go @@ -40,7 +40,7 @@ var ( ErrNoHandlers = errors.New("format: at least one handler is required, but none were set") ) -// gorilla/schema errors +// gofiber/schema errors type ( // ConversionError Conversion error exposes the internal schema.ConversionError for public use. ConversionError = schema.ConversionError