mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
fix(ftx/rest): add Id() for setting restful id
This commit is contained in:
parent
2467d3fcf6
commit
7fd3375741
|
@ -40,6 +40,9 @@ type restRequest struct {
|
||||||
|
|
||||||
// payload
|
// payload
|
||||||
p map[string]interface{}
|
p map[string]interface{}
|
||||||
|
|
||||||
|
// object id
|
||||||
|
id string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRestRequest(c *http.Client, baseURL *url.URL) *restRequest {
|
func newRestRequest(c *http.Client, baseURL *url.URL) *restRequest {
|
||||||
|
@ -80,13 +83,23 @@ func (r *restRequest) ReferenceURL(refURL string) *restRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *restRequest) buildURL() (*url.URL, error) {
|
func (r *restRequest) buildURL() (*url.URL, error) {
|
||||||
refURL, err := url.Parse(r.refURL)
|
u := r.refURL
|
||||||
|
if len(r.id) > 0 {
|
||||||
|
u = u + "/" + r.id
|
||||||
|
}
|
||||||
|
refURL, err := url.Parse(u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.baseURL.ResolveReference(refURL), nil
|
return r.baseURL.ResolveReference(refURL), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *restRequest) Id(id string) *restRequest {
|
||||||
|
r.id = id
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
func (r *restRequest) Payloads(payloads map[string]interface{}) *restRequest {
|
func (r *restRequest) Payloads(payloads map[string]interface{}) *restRequest {
|
||||||
for k, v := range payloads {
|
for k, v := range payloads {
|
||||||
r.p[k] = v
|
r.p[k] = v
|
||||||
|
|
Loading…
Reference in New Issue
Block a user