forked from TrueCloudLab/rclone
rest: add Parameters field to opts for adding URL parameters
This commit is contained in:
parent
45ba4ed594
commit
088806ba4c
1 changed files with 9 additions and 4 deletions
13
rest/rest.go
13
rest/rest.go
|
@ -10,6 +10,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
"github.com/ncw/rclone/fs"
|
||||||
|
@ -90,10 +91,11 @@ type Opts struct {
|
||||||
UserName string // username for Basic Auth
|
UserName string // username for Basic Auth
|
||||||
Password string // password for Basic Auth
|
Password string // password for Basic Auth
|
||||||
Options []fs.OpenOption
|
Options []fs.OpenOption
|
||||||
IgnoreStatus bool // if set then we don't check error status or parse error body
|
IgnoreStatus bool // if set then we don't check error status or parse error body
|
||||||
MultipartMetadataName string // set the following 3 vars
|
MultipartMetadataName string // set the following 3 vars
|
||||||
MultipartContentName string // and Body and pass in request
|
MultipartContentName string // and Body and pass in request
|
||||||
MultipartFileName string // for multipart upload
|
MultipartFileName string // for multipart upload
|
||||||
|
Parameters url.Values // any parameters for the final URL
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy creates a copy of the options
|
// 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
|
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)
|
req, err := http.NewRequest(opts.Method, url, opts.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Reference in a new issue