π Documentation improvement (BodyParser section):
Hi! In the documentation, incomplete information about the request body parser. It took a long time to find a way to send arrays in parameters. I suggest adding an example to the documentation.
// curl -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "users.0.name=john&users.1.name=jack" localhost:3000
type User struct {
Name string `json:"name" xml:"name" form:"name"`
}
var users []User
app.Post("/", func(c *fiber.Ctx) error {
if err := c.BodyParser(&users); err != nil {
return err
}
log.Println(users[0].Name) // john
log.Println(users[1].Name) // jack
// ...
})
users.0.name=john&users.1.name=jack looks strange, I think it must be like users[0][βnameβ]=john&users[1][βnameβ]=jack
users.0.name=john&users.1.name=jacklooks strange, I think it must be likeusers[0][βnameβ]=john&users[1][βnameβ]=jack
They're both supported
users.0.name=john&users.1.name=jack looks strange, I think it must be like users[0][βnameβ]=john&users[1][βnameβ]=jack
this one can be added too. The fiber tests have several options.
@smalloff can you create a pull request for this ?