MCPcopy
hub / github.com/dgraph-io/dgraph / doPost

Method doPost

dgraphapi/cluster.go:256–271  ·  view source on GitHub ↗

doPost makes a post request to the 'url' endpoint

(body []byte, url string, contentType string)

Source from the content-addressed store, hash-verified

254
255// doPost makes a post request to the 'url' endpoint
256func (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
274func (hc *HTTPClient) RunGraphqlQuery(params GraphQLParams, admin bool) ([]byte, error) {

Callers 1

RunGraphqlQueryMethod · 0.95

Calls 2

DoReqFunction · 0.85
AddMethod · 0.45

Tested by

no test coverage detected