Skip to content

Commit

Permalink
fix(internal): fix net.IPNet and scw.IPNet in query param (#1843)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtherin committed Sep 20, 2023
1 parent d2f8a2e commit 6b599c2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/parameter/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/url"
"reflect"
"time"
"github.com/scaleway/scaleway-sdk-go/scw"
)

// AddToQuery add a key/value pair to an URL query
Expand All @@ -24,6 +25,10 @@ func AddToQuery(query url.Values, key string, value interface{}) {
switch {
case elemType == reflect.TypeOf(net.IP{}):
query.Add(key, value.(*net.IP).String())
case elemType == reflect.TypeOf(net.IPNet{}):
query.Add(key, value.(*net.IPNet).String())
case elemType == reflect.TypeOf(scw.IPNet{}):
query.Add(key, value.(*scw.IPNet).String())
case elemType.Kind() == reflect.Slice:
for i := 0; i < elemValue.Len(); i++ {
query.Add(key, fmt.Sprint(elemValue.Index(i).Interface()))
Expand Down

0 comments on commit 6b599c2

Please sign in to comment.