type Person struct {
Name string `json:"name" xml:"name" form:"name"`
Pass string `json:"pass" xml:"pass" form:"pass"`
}
app.Post("/", func(c *fiber.Ctx) error {
p := new(Person)
if err := c.BodyParser(p); err != nil {
return err
}
log.Println(p.Name) // john
log.Println(p.Pass) // doe
// ...
})
Above is the code to Parse a POST request with a struct. In my case, the number of POST parameters can be any number. How will it be parsed in that situation?
You may find that creating an empty map will work, this code is from enter link description here as follows:(Edited to simplify)
So you would
In this example. Hope it helps.