Skip to content

Commit 06dc738

Browse files
authored
feat(sdk): add WithQueryParameter request modifier (#5139)
Signed-off-by: francois samin <[email protected]>
1 parent 8729e39 commit 06dc738

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sdk/cdsclient/http.go

+9
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ func SetHeader(key, value string) RequestModifier {
5151
}
5252
}
5353

54+
// WithQueryParameter add query parameters to your http.Request
55+
func WithQueryParameter(key, value string) RequestModifier {
56+
return func(req *http.Request) {
57+
q := req.URL.Query()
58+
q.Set(key, value)
59+
req.URL.RawQuery = q.Encode()
60+
}
61+
}
62+
5463
// PostJSON post the *in* struct as json. If set, it unmarshalls the response to *out*
5564
func (c *client) PostJSON(ctx context.Context, path string, in interface{}, out interface{}, mods ...RequestModifier) (int, error) {
5665
_, _, code, err := c.RequestJSON(ctx, http.MethodPost, path, in, out, mods...)

0 commit comments

Comments
 (0)