QueryParser
This method is similar to BodyParser, but for query parameters.
c.QueryParser(out interface{}) error
// Field names should start with an uppercase letter
type Person struct {
Name string `query:"name"`
Pass string `query:"pass"`
Products []string `query:"products"`
}
app.Post("/", func(c *fiber.Ctx) {
p := new(Person)
if err := c.QueryParser(p); err != nil {
log.Fatal(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 -X POST "http://localhost:3000/?name=john&pass=doe&products=shoe,hat"