cluade code review changes
This commit is contained in:
@@ -35,10 +35,21 @@ func NumberParam[T Number](r *http.Request, key string) (T, error) {
|
||||
return T(n), nil
|
||||
}
|
||||
|
||||
// int param
|
||||
// unsigned int param
|
||||
if k >= reflect.Uint && k <= reflect.Uint64 {
|
||||
n, err := strconv.ParseUint(p, 10, 64)
|
||||
if err != nil {
|
||||
return noop, fmt.Errorf("query param: %q is not a valid unsigned integer", key)
|
||||
}
|
||||
|
||||
return T(n), nil
|
||||
}
|
||||
|
||||
// signed int param
|
||||
n, err := strconv.ParseInt(p, 10, 64)
|
||||
if err != nil {
|
||||
return noop, fmt.Errorf("query param: %q is not a valid integer", key)
|
||||
}
|
||||
|
||||
return T(n), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user