Skip to content

Commit

Permalink
Revert "Adding support for array query params"
Browse files Browse the repository at this point in the history
This reverts commit 2aa7a03.
  • Loading branch information
Lucas Hinderberger committed Jul 10, 2024
1 parent 86953e9 commit b79658d
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions pkg/lib/api/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"net/http/httputil"
"net/url"
"path"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -117,35 +116,18 @@ func (request Request) buildHttpRequest() (req *http.Request, err error) {

q := req.URL.Query()

addToQuery := func(key string, val any) error {
var vs []any

refval := reflect.ValueOf(val)

switch refval.Kind() {
case reflect.Array, reflect.Slice:
l := refval.Len()
vs = make([]any, l)
for i := 0; i < l; i++ {
vs[i] = refval.Index(i).Interface()
}
default:
vs = []any{val}
addToQuery := func(key string, v any) error {
stringVal, err := util.GetStringFromInterface(v)
if err != nil {
return fmt.Errorf("error GetStringFromInterface: %s", err)
}

for _, v := range vs {
stringVal, err := util.GetStringFromInterface(v)
if err != nil {
return fmt.Errorf("error GetStringFromInterface: %s", err)
}

if stringVal == "" {
return nil
}

q.Add(key, stringVal)
if stringVal == "" {
return nil
}

q.Add(key, stringVal)

return nil
}

Expand Down

0 comments on commit b79658d

Please sign in to comment.