doPost makes a post request to the 'url' endpoint
(body []byte, url string, contentType string)
| 254 | |
| 255 | // doPost makes a post request to the 'url' endpoint |
| 256 | func (hc *HTTPClient) doPost(body []byte, url string, contentType string) ([]byte, error) { |
| 257 | req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(body)) |
| 258 | if err != nil { |
| 259 | return nil, errors.Wrapf(err, "error building req for endpoint [%v]", url) |
| 260 | } |
| 261 | req.Header.Add("Content-Type", contentType) |
| 262 | |
| 263 | if hc.HttpToken != nil { |
| 264 | req.Header.Add("X-Dgraph-AccessToken", hc.AccessJwt) |
| 265 | } |
| 266 | if hc.AuthToken != "" { |
| 267 | req.Header.Add("X-Dgraph-AuthToken", hc.AuthToken) |
| 268 | } |
| 269 | |
| 270 | return DoReq(req) |
| 271 | } |
| 272 | |
| 273 | // RunGraphqlQuery makes a query to graphql (or admin) endpoint |
| 274 | func (hc *HTTPClient) RunGraphqlQuery(params GraphQLParams, admin bool) ([]byte, error) { |
no test coverage detected