Skip to content

Commit

Permalink
Revert "Moving addToQuery to dedicated function"
Browse files Browse the repository at this point in the history
This reverts commit ed148f8.
  • Loading branch information
Lucas Hinderberger committed Jul 10, 2024
1 parent b79658d commit 1f98ea0
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions pkg/lib/api/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,6 @@ func (request Request) buildHttpRequest() (req *http.Request, err error) {

q := req.URL.Query()

addToQuery := func(key string, v any) error {
stringVal, err := util.GetStringFromInterface(v)
if err != nil {
return fmt.Errorf("error GetStringFromInterface: %s", err)
}

if stringVal == "" {
return nil
}

q.Add(key, stringVal)

return nil
}

for queryName, datastoreKey := range request.QueryParamsFromStore {
skipOnError := false
if len(datastoreKey) > 0 && datastoreKey[0] == '?' {
Expand All @@ -150,17 +135,23 @@ func (request Request) buildHttpRequest() (req *http.Request, err error) {
return nil, fmt.Errorf("could not get '%s' from Datastore: %s", datastoreKey, err)
}

err = addToQuery(queryName, queryParamInterface)
stringVal, err := util.GetStringFromInterface(queryParamInterface)
if err != nil {
return req, err
return req, fmt.Errorf("error GetStringFromInterface: %s", err)
}

if stringVal == "" {
continue
}
q.Add(queryName, stringVal)
}

for key, val := range request.QueryParams {
err = addToQuery(key, val)
stringVal, err := util.GetStringFromInterface(val)
if err != nil {
return req, err
return req, fmt.Errorf("error GetStringFromInterface: %s", err)
}
q.Set(key, stringVal)
}

req.URL.RawQuery = q.Encode()
Expand Down

0 comments on commit 1f98ea0

Please sign in to comment.