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

Function MakeHttpRequest

graphql/schema/custom_http.go:35–54  ·  view source on GitHub ↗

MakeHttpRequest sends an HTTP request using the provided inputs. It returns the HTTP response along with any errors that were encountered. If no client is provided, it uses the defaultHttpClient which has a timeout of 1 minute.

(client *http.Client, method, url string, header http.Header,
	body []byte)

Source from the content-addressed store, hash-verified

33// along with any errors that were encountered.
34// If no client is provided, it uses the defaultHttpClient which has a timeout of 1 minute.
35func MakeHttpRequest(client *http.Client, method, url string, header http.Header,
36 body []byte) (*http.Response, error) {
37 var reqBody io.Reader
38 if len(body) == 0 {
39 reqBody = http.NoBody
40 } else {
41 reqBody = bytes.NewReader(body)
42 }
43
44 req, err := http.NewRequest(method, url, reqBody)
45 if err != nil {
46 return nil, err
47 }
48 req.Header = header
49
50 if client == nil {
51 client = defaultHttpClient
52 }
53 return client.Do(req)
54}
55
56// MakeAndDecodeHTTPRequest sends an HTTP request using the given url and body and then decodes the
57// response correctly based on whether it was a GraphQL or REST request.

Callers 2

sendWebhookEventFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected