ParamsInt
Method can be used to get an integer from the route parameters. Please note if that parameter is not in the request, zero will be returned. If the parameter is NOT a number, zero and an error will be returned
Defaults to empty string (""
), if the param doesn’t exist.
func (c *Ctx) Params(key string) (int, error)
// GET http://example.com/user/123
app.Get("/user/:name", func(c *fiber.Ctx) error {
id, err := c.ParamsInt("id") // int 123 and no error
// ...
})
This method is equivalent of using atoi
with ctx.Params