MCPcopy Index your code
hub / github.com/vektra/mockery / httpsGet

Function httpsGet

internal/remote_template.go:15–35  ·  view source on GitHub ↗
(ctx context.Context, url string)

Source from the content-addressed store, hash-verified

13)
14
15func httpsGet(ctx context.Context, url string) (string, error) {
16 log := zerolog.Ctx(ctx)
17 //nolint: gosec
18 response, err := http.Get(url)
19 if err != nil {
20 log.Err(err).Msg("failed to download file")
21 return "", fmt.Errorf("downloading file: %w", err)
22 }
23 defer response.Body.Close()
24 body, err := io.ReadAll(response.Body)
25 if err != nil {
26 log.Err(err).Msg("failed to read response body")
27 return "", fmt.Errorf("reading response body: %w", err)
28 }
29 if response.StatusCode != 200 {
30 log.Debug().Int("status-code", response.StatusCode).Msg("got non-200 response when downloading file. Logging response body:")
31 log.Debug().Msg(string(body))
32 return "", fmt.Errorf("got http code %d: %w", response.StatusCode, errBadHTTPStatus)
33 }
34 return string(body), nil
35}
36
37func download(ctx context.Context, url string) (string, error) {
38 if strings.HasPrefix(url, "file://") {

Callers 1

downloadFunction · 0.85

Calls 2

GetMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…