Skip to content

Commit 1f98ea0

Browse files
author
Lucas Hinderberger
committed
Revert "Moving addToQuery to dedicated function"
This reverts commit ed148f8.
1 parent b79658d commit 1f98ea0

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

pkg/lib/api/request.go

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,6 @@ func (request Request) buildHttpRequest() (req *http.Request, err error) {
116116

117117
q := req.URL.Query()
118118

119-
addToQuery := func(key string, v any) error {
120-
stringVal, err := util.GetStringFromInterface(v)
121-
if err != nil {
122-
return fmt.Errorf("error GetStringFromInterface: %s", err)
123-
}
124-
125-
if stringVal == "" {
126-
return nil
127-
}
128-
129-
q.Add(key, stringVal)
130-
131-
return nil
132-
}
133-
134119
for queryName, datastoreKey := range request.QueryParamsFromStore {
135120
skipOnError := false
136121
if len(datastoreKey) > 0 && datastoreKey[0] == '?' {
@@ -150,17 +135,23 @@ func (request Request) buildHttpRequest() (req *http.Request, err error) {
150135
return nil, fmt.Errorf("could not get '%s' from Datastore: %s", datastoreKey, err)
151136
}
152137

153-
err = addToQuery(queryName, queryParamInterface)
138+
stringVal, err := util.GetStringFromInterface(queryParamInterface)
154139
if err != nil {
155-
return req, err
140+
return req, fmt.Errorf("error GetStringFromInterface: %s", err)
141+
}
142+
143+
if stringVal == "" {
144+
continue
156145
}
146+
q.Add(queryName, stringVal)
157147
}
158148

159149
for key, val := range request.QueryParams {
160-
err = addToQuery(key, val)
150+
stringVal, err := util.GetStringFromInterface(val)
161151
if err != nil {
162-
return req, err
152+
return req, fmt.Errorf("error GetStringFromInterface: %s", err)
163153
}
154+
q.Set(key, stringVal)
164155
}
165156

166157
req.URL.RawQuery = q.Encode()

0 commit comments

Comments
 (0)