QueryParser
This method is similar to BodyParser, but for query parameters.
func (c *Ctx) 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.Get("/", func(c *fiber.Ctx) error {
p := new(Person)
if err := c.QueryParser(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 -X POST "http://localhost:3000/?name=john&pass=doe&products=shoe,hat"