@@ -187,10 +187,22 @@ func SetDDIAPI() func(*Client) {
187
187
return func (c * Client ) { c .DDI = true }
188
188
}
189
189
190
+ // Param is a container struct which holds a `Key` and `Value` field corresponding to the values of a URL parameter.
191
+ type Param struct {
192
+ Key , Value string
193
+ }
194
+
190
195
// Do satisfies the Doer interface. resp will be nil if a non-HTTP error
191
196
// occurs, otherwise it is available for inspection when the error reflects a
192
- // non-2XX response.
193
- func (c Client ) Do (req * http.Request , v interface {}) (* http.Response , error ) {
197
+ // non-2XX response. It accepts a variadic number of optional URL parameters to
198
+ // supply to the request. URL parameters are of type `rest.Param`.
199
+ func (c Client ) Do (req * http.Request , v interface {}, params ... Param ) (* http.Response , error ) {
200
+ q := req .URL .Query ()
201
+ for _ , p := range params {
202
+ q .Set (p .Key , p .Value )
203
+ }
204
+ req .URL .RawQuery = q .Encode ()
205
+
194
206
resp , err := c .httpClient .Do (req )
195
207
if err != nil {
196
208
return nil , err
@@ -229,9 +241,11 @@ type NextFunc func(v *interface{}, uri string) (*http.Response, error)
229
241
// DoWithPagination Does, and follows Link headers for pagination. The returned
230
242
// Response is from the last URI visited - either the last page, or one that
231
243
// responded with a non-2XX status. If a non-HTTP error occurs, resp will be
232
- // nil.
233
- func (c Client ) DoWithPagination (req * http.Request , v interface {}, f NextFunc ) (* http.Response , error ) {
234
- resp , err := c .Do (req , v )
244
+ // nil. It accepts a variadic number of optional URL parameters to supply to
245
+ // the underlying `.Do()` method request(s). URL parameters are of type
246
+ // `rest.Param`.
247
+ func (c Client ) DoWithPagination (req * http.Request , v interface {}, f NextFunc , params ... Param ) (* http.Response , error ) {
248
+ resp , err := c .Do (req , v , params ... )
235
249
if err != nil {
236
250
return resp , err
237
251
}
0 commit comments