MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / NewHTTPFetcher

Function NewHTTPFetcher

lib/httputils/fetcher.go:74–85  ·  view source on GitHub ↗

NewHTTPFetcher creates a new HTTPFetcher with the given endpoint and HTTP client.

(
	endpoint string, httpClient *http.Client)

Source from the content-addressed store, hash-verified

72
73// NewHTTPFetcher creates a new HTTPFetcher with the given endpoint and HTTP client.
74func NewHTTPFetcher(
75 endpoint string, httpClient *http.Client) (*HTTPFetcher, error) {
76 u, err := url.Parse(endpoint)
77 if err != nil {
78 return nil, errors.Join(ErrUnableToParseURL, err)
79 }
80
81 return &HTTPFetcher{
82 httpClient: httpClient,
83 endpoint: u,
84 }, nil
85}
86
87// Fetch performs an HTTP GET request to the configured endpoint.
88// It returns the response body as an io.ReadCloser on success.

Callers 2

TestNewHTTPFetcherFunction · 0.85
TestHTTPFetcher_FetchFunction · 0.85

Calls 1

ParseMethod · 0.65

Tested by 2

TestNewHTTPFetcherFunction · 0.68
TestHTTPFetcher_FetchFunction · 0.68