(req *http.Request)
| 95 | } |
| 96 | |
| 97 | func 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 | |
| 118 | func (hc *HTTPClient) LoginUsingToken(ns uint64) error { |
| 119 | q := `mutation login( $namespace: Int, $refreshToken:String) { |
no test coverage detected