Skip to content

Commit 6d7b776

Browse files
committed
refactor: type checking options in http client
1 parent 4373bad commit 6d7b776

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

http/client.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,17 @@ func getQuery(req *cmds.Request) (string, error) {
231231
continue
232232
}
233233

234-
optArr, ok := v.([]string)
235-
if ok {
236-
for _, o := range optArr {
234+
switch val := v.(type) {
235+
case []string:
236+
for _, o := range val {
237237
query.Add(k, o)
238238
}
239-
continue
239+
case bool, int, int64, uint, uint64, float64, string:
240+
str := fmt.Sprintf("%v", v)
241+
query.Set(k, str)
242+
default:
243+
return "", fmt.Errorf("unsupported query parameter type. key: %s, value: %v", k, v)
240244
}
241-
242-
str := fmt.Sprintf("%v", v)
243-
query.Set(k, str)
244245
}
245246

246247
args := req.Arguments

0 commit comments

Comments
 (0)