Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ func (b *Bind) XML(out any) error {

// Form binds the form into the struct, map[string]string and map[string][]string.
// If Content-Type is "application/x-www-form-urlencoded" or "multipart/form-data", it will bind the form values.
//
// Binding multipart files is not supported yet.
// Multipart file fields are supported using *multipart.FileHeader, []*multipart.FileHeader, or *[]*multipart.FileHeader.
func (b *Bind) Form(out any) error {
bind := binder.GetFromThePool[*binder.FormBinding](&binder.FormBinderPool)
bind.EnableSplitting = b.ctx.App().config.EnableSplittingOnParsers
Expand Down
2 changes: 1 addition & 1 deletion docs/api/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ If not provided, TestConfig is set to the following defaults:

```go title="Default TestConfig"
config := fiber.TestConfig{
Timeout: time.Second(),
Timeout: time.Second,
FailOnTimeout: true,
}
```
Expand Down
36 changes: 24 additions & 12 deletions docs/api/bind.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ The binding sources have the following precedence:
4. **Request Headers**
5. **Cookies**

:::info
The request body is only included as a binding source when the request has both a non-empty body **and** a non-empty `Content-Type` header.
:::

```go title="Signature"
func (b *Bind) All(out any) error
```
Expand Down Expand Up @@ -614,15 +618,23 @@ func (b *Bind) SkipValidation(skip bool) *Bind
Allows you to configure the BodyParser/QueryParser decoder based on schema options, providing the possibility to add custom types for parsing.

```go title="Signature"
func SetParserDecoder(parserConfig fiber.ParserConfig{
IgnoreUnknownKeys bool,
ParserType []fiber.ParserType{
Customtype any,
Converter func(string) reflect.Value,
},
ZeroEmpty bool,
SetAliasTag string,
})
binder.SetParserDecoder(parserConfig binder.ParserConfig)
```
Comment thread
ReneWerner87 marked this conversation as resolved.
Outdated

`binder.ParserConfig` has the following fields:

```go
type ParserConfig struct {
IgnoreUnknownKeys bool
ParserType []ParserType
ZeroEmpty bool
SetAliasTag string
}

type ParserType struct {
CustomType any
Converter func(string) reflect.Value
}
```

```go title="Example"
Expand All @@ -644,15 +656,15 @@ var timeConverter = func(value string) reflect.Value {
return reflect.Value{}
}

customTime := fiber.ParserType{
customTime := binder.ParserType{
CustomType: CustomTime{},
Converter: timeConverter,
}

// Add custom type to the Decoder settings
fiber.SetParserDecoder(fiber.ParserConfig{
binder.SetParserDecoder(binder.ParserConfig{
IgnoreUnknownKeys: true,
ParserType: []fiber.ParserType{customTime},
ParserType: []binder.ParserType{customTime},
ZeroEmpty: true,
})

Expand Down
Loading
Loading