(hostname string, method string, p string, body io.Reader, data any)
| 164 | } |
| 165 | |
| 166 | func (c Client) RESTWithNext(hostname string, method string, p string, body io.Reader, data any) (string, error) { |
| 167 | opts := clientOptions(hostname, c.http.Transport) |
| 168 | restClient, err := ghAPI.NewRESTClient(opts) |
| 169 | if err != nil { |
| 170 | return "", err |
| 171 | } |
| 172 | |
| 173 | resp, err := restClient.Request(method, p, body) |
| 174 | if err != nil { |
| 175 | return "", handleResponse(err) |
| 176 | } |
| 177 | defer resp.Body.Close() |
| 178 | |
| 179 | if resp.StatusCode == http.StatusNoContent { |
| 180 | return "", nil |
| 181 | } |
| 182 | |
| 183 | b, err := io.ReadAll(resp.Body) |
| 184 | if err != nil { |
| 185 | return "", err |
| 186 | } |
| 187 | |
| 188 | err = json.Unmarshal(b, &data) |
| 189 | if err != nil { |
| 190 | return "", err |
| 191 | } |
| 192 | |
| 193 | var next string |
| 194 | for _, m := range linkRE.FindAllStringSubmatch(resp.Header.Get("Link"), -1) { |
| 195 | if len(m) > 2 && m[2] == "next" { |
| 196 | next = m[1] |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | return next, nil |
| 201 | } |
| 202 | |
| 203 | // Request performs a REST request and returns the response for the caller to consume. |
| 204 | // |
nothing calls this directly
no test coverage detected