-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace vendored gorilla/schema package
- Loading branch information
Showing
13 changed files
with
47 additions
and
1,364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -573,3 +573,40 @@ app.Post("/", func(c fiber.Ctx) error { | |
} | ||
}) | ||
``` | ||
|
||
## Default Fields | ||
|
||
You can set default values for fields in the struct by using the `default` struct tag. Supported types: | ||
- bool | ||
Check failure on line 580 in docs/api/bind.md GitHub Actions / markdownlintLists should be surrounded by blank lines
|
||
- float variants (float32, float64) | ||
- int variants (int, int8, int16, int32, int64) | ||
- uint variants (uint, uint8, uint16, uint32, uint64) | ||
- string | ||
- a slice of the above types. As shown in the example above, **| should be used to separate between slice items**. | ||
- a pointer to one of the above types **(pointer to slice and slice of pointers are not supported)**. | ||
|
||
|
||
Check failure on line 588 in docs/api/bind.md GitHub Actions / markdownlintMultiple consecutive blank lines
|
||
```go title="Example" | ||
type Person struct { | ||
Name string `query:"name,default:john"` | ||
Pass string `query:"pass"` | ||
Products []string `query:"products,default:shoe|hat"` | ||
} | ||
|
||
app.Get("/", func(c fiber.Ctx) error { | ||
p := new(Person) | ||
|
||
if err := c.Bind().Query(p); err != nil { | ||
return err | ||
} | ||
|
||
log.Println(p.Name) // john | ||
log.Println(p.Pass) // doe | ||
log.Println(p.Products) // ["shoe,hat"] | ||
|
||
// ... | ||
}) | ||
// Run tests with the following curl command | ||
|
||
// curl "http://localhost:3000/?pass=doe" | ||
``` | ||
Check failure on line 612 in docs/api/bind.md GitHub Actions / markdownlintFiles should end with a single newline character
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.