OptionalIntParamWithDefault is a helper function that can be used to fetch a requested parameter from the request similar to optionalIntParam, but it also takes a default value.
(args map[string]any, p string, d int)
| 214 | // OptionalIntParamWithDefault is a helper function that can be used to fetch a requested parameter from the request |
| 215 | // similar to optionalIntParam, but it also takes a default value. |
| 216 | func OptionalIntParamWithDefault(args map[string]any, p string, d int) (int, error) { |
| 217 | v, err := OptionalIntParam(args, p) |
| 218 | if err != nil { |
| 219 | return 0, err |
| 220 | } |
| 221 | if v == 0 { |
| 222 | return d, nil |
| 223 | } |
| 224 | return v, nil |
| 225 | } |
| 226 | |
| 227 | // OptionalBoolParamWithDefault is a helper function that can be used to fetch a requested parameter from the request |
| 228 | // similar to optionalBoolParam, but it also takes a default value. |