rest: add Parameters field to opts for adding URL parameters

This commit is contained in:
Nick Craig-Wood 2017-07-06 12:12:01 +01:00
parent 45ba4ed594
commit 088806ba4c

View file

@ -10,6 +10,7 @@ import (
"io/ioutil"
"mime/multipart"
"net/http"
"net/url"
"sync"
"github.com/ncw/rclone/fs"
@ -94,6 +95,7 @@ type Opts struct {
MultipartMetadataName string // set the following 3 vars
MultipartContentName string // and Body and pass in request
MultipartFileName string // for multipart upload
Parameters url.Values // any parameters for the final URL
}
// Copy creates a copy of the options
@ -153,6 +155,9 @@ func (api *Client) Call(opts *Opts) (resp *http.Response, err error) {
}
url = api.rootURL + opts.Path
}
if opts.Parameters != nil && len(opts.Parameters) > 0 {
url += "?" + opts.Parameters.Encode()
}
req, err := http.NewRequest(opts.Method, url, opts.Body)
if err != nil {
return