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

Function DoReq

dgraphapi/cluster.go:97–116  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

95}
96
97func DoReq(req *http.Request) ([]byte, error) {
98 resp, err := client.Do(req)
99 if err != nil {
100 return nil, errors.Wrap(err, "error performing HTTP request")
101 }
102 defer func() {
103 if err := resp.Body.Close(); err != nil {
104 log.Printf("[WARNING] error closing response body: %v", err)
105 }
106 }()
107
108 respBody, err := io.ReadAll(resp.Body)
109 if err != nil {
110 return nil, errors.Wrapf(err, "error reading response body: url: [%v], err: [%v]", req.URL, err)
111 }
112 if resp.StatusCode != http.StatusOK {
113 return nil, fmt.Errorf("got non 200 resp: %v", string(respBody))
114 }
115 return respBody, nil
116}
117
118func (hc *HTTPClient) LoginUsingToken(ns uint64) error {
119 q := `mutation login( $namespace: Int, $refreshToken:String) {

Callers 6

containerHealthCheckMethod · 0.92
AlphasHealthMethod · 0.92
AssignUidsMethod · 0.92
doPostMethod · 0.85
PostDqlQueryMethod · 0.85
MutateMethod · 0.85

Calls 2

CloseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected