(hostname string, method string, p string, body io.Reader, data interface{})
| 111 | } |
| 112 | |
| 113 | func (c Client) RESTWithNext(hostname string, method string, p string, body io.Reader, data interface{}) (string, error) { |
| 114 | opts := clientOptions(hostname, c.http.Transport) |
| 115 | restClient, err := ghAPI.NewRESTClient(opts) |
| 116 | if err != nil { |
| 117 | return "", err |
| 118 | } |
| 119 | |
| 120 | resp, err := restClient.Request(method, p, body) |
| 121 | if err != nil { |
| 122 | return "", handleResponse(err) |
| 123 | } |
| 124 | defer resp.Body.Close() |
| 125 | |
| 126 | if resp.StatusCode == http.StatusNoContent { |
| 127 | return "", nil |
| 128 | } |
| 129 | |
| 130 | b, err := io.ReadAll(resp.Body) |
| 131 | if err != nil { |
| 132 | return "", err |
| 133 | } |
| 134 | |
| 135 | err = json.Unmarshal(b, &data) |
| 136 | if err != nil { |
| 137 | return "", err |
| 138 | } |
| 139 | |
| 140 | var next string |
| 141 | for _, m := range linkRE.FindAllStringSubmatch(resp.Header.Get("Link"), -1) { |
| 142 | if len(m) > 2 && m[2] == "next" { |
| 143 | next = m[1] |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | return next, nil |
| 148 | } |
| 149 | |
| 150 | // HandleHTTPError parses a http.Response into a HTTPError. |
| 151 | // |
nothing calls this directly
no test coverage detected