DoRequest sends a request with body to ES.
(method string, url string, body *bytes.Buffer)
| 186 | |
| 187 | // DoRequest sends a request with body to ES. |
| 188 | func (c *Client) DoRequest(method string, url string, body *bytes.Buffer) (*http.Response, error) { |
| 189 | req, err := http.NewRequest(method, url, body) |
| 190 | req.Header.Add("Content-Type", "application/json") |
| 191 | if err != nil { |
| 192 | return nil, errors.Trace(err) |
| 193 | } |
| 194 | if len(c.User) > 0 && len(c.Password) > 0 { |
| 195 | req.SetBasicAuth(c.User, c.Password) |
| 196 | } |
| 197 | resp, err := c.c.Do(req) |
| 198 | |
| 199 | return resp, err |
| 200 | } |
| 201 | |
| 202 | // Do sends the request with body to ES. |
| 203 | func (c *Client) Do(method string, url string, body map[string]interface{}) (*Response, error) { |
no test coverage detected