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.

  1. func (c *Ctx) Params(key string) (int, error)
  1. // GET http://example.com/user/123
  2. app.Get("/user/:name", func(c *fiber.Ctx) error {
  3. id, err := c.ParamsInt("id") // int 123 and no error
  4. // ...
  5. })

This method is equivalent of using atoi with ctx.Params