MCPcopy
hub / github.com/redspread/spread / fetch

Function fetch

pkg/packages/discovery.go:117–130  ·  view source on GitHub ↗

fetch retrieves the package using the given scheme and returns the response and a string of the URL of the fetch.

(scheme, packageName string, verbose bool)

Source from the content-addressed store, hash-verified

115
116// fetch retrieves the package using the given scheme and returns the response and a string of the URL of the fetch.
117func fetch(scheme, packageName string, verbose bool) (string, *http.Response, error) {
118 u, err := url.Parse(scheme + "://" + packageName)
119 if err != nil {
120 return "", nil, err
121 }
122 u.RawQuery = DiscoveryQueryParam
123 urlStr := u.String()
124 if verbose {
125 fmt.Fprintf(config.Out, "fetching %s", urlStr)
126 }
127
128 res, err := httpClient.Get(urlStr)
129 return urlStr, res, err
130}
131
132// parseSpreadRefs reads an HTML document from r and uses it to return information about the package.
133// Information is currently stored in a <meta> tag with the name "spread-ref". Based on Go Get parsing code.

Callers 1

DiscoverPackageFunction · 0.85

Calls 2

StringMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected