buildRequestWithBody builds an HTTP request with a body.
(method, url string, body interface{})
| 97 | |
| 98 | // buildRequestWithBody builds an HTTP request with a body. |
| 99 | func (c *Client) buildRequestWithBody(method, url string, body interface{}) (*http.Request, error) { |
| 100 | var r io.ReadCloser |
| 101 | if body != nil { |
| 102 | b, err := json.Marshal(body) |
| 103 | if err != nil { |
| 104 | return nil, err |
| 105 | } |
| 106 | |
| 107 | r = io.NopCloser(bytes.NewReader(b)) |
| 108 | } |
| 109 | |
| 110 | return http.NewRequest(method, url, r) |
| 111 | } |
| 112 | |
| 113 | // buildRequest builds an HTTP request. |
| 114 | func (c *Client) buildRequest( |