request.go 303 B

1234567891011121314151617181920
  1. package request
  2. import (
  3. "errors"
  4. "github.com/gofiber/fiber/v2"
  5. )
  6. func ConvertToUint64(fctx *fiber.Ctx, key string) (uint64, error) {
  7. val, err := fctx.ParamsInt(key)
  8. if err != nil {
  9. return 0, err
  10. }
  11. if val < 0 {
  12. return 0, errors.New("value must be positive")
  13. }
  14. return uint64(val), nil
  15. }