Open mybigman opened 1 week ago
It's a really good idea. I'm a little busy now, but I'll look into it at the first chance.
i created this... feel free to use it
func GetQueryParamWithDefault[T any](r *http.Request, key string, val T) T {
value := r.URL.Query().Get(key)
if value == "" {
return val
}
switch any(val).(type) {
case int:
if intValue, err := strconv.Atoi(value); err == nil {
return any(intValue).(T)
}
case float64:
if floatValue, err := strconv.ParseFloat(value, 64); err == nil {
return any(floatValue).(T)
}
case string:
return any(value).(T)
}
return val
}
Appreciate it. Have you considered making pull requests?
I will when I am feeling better, everyone in our house hold are so sick :(
I hope you're getting well soon.
Since you have the following helpers
Could you add say
Thanks