MCPcopy Create free account
hub / github.com/cli/cli / apiGet

Function apiGet

pkg/cmd/run/shared/artifacts.go:61–83  ·  view source on GitHub ↗
(httpClient *http.Client, url safeurl.SafeURL, data interface{})

Source from the content-addressed store, hash-verified

59}
60
61func apiGet(httpClient *http.Client, url safeurl.SafeURL, data interface{}) (string, error) {
62 req, err := http.NewRequest("GET", url.String(), nil)
63 if err != nil {
64 return "", err
65 }
66
67 resp, err := httpClient.Do(req)
68 if err != nil {
69 return "", err
70 }
71 defer resp.Body.Close()
72
73 if resp.StatusCode > 299 {
74 return "", api.HandleHTTPError(resp)
75 }
76
77 dec := json.NewDecoder(resp.Body)
78 if err := dec.Decode(data); err != nil {
79 return "", err
80 }
81
82 return findNextPage(resp), nil
83}
84
85var linkRE = regexp.MustCompile(`<([^>]+)>;\s*rel="([^"]+)"`)
86

Callers 1

ListArtifactsFunction · 0.85

Calls 5

HandleHTTPErrorFunction · 0.92
findNextPageFunction · 0.70
StringMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected