FromHTTP returns an object to fetch files from a webserver.
(client *http.Client, rootURL string)
| 62 | |
| 63 | // FromHTTP returns an object to fetch files from a webserver. |
| 64 | func FromHTTP(client *http.Client, rootURL string) (Interface, error) { |
| 65 | var root *url.URL |
| 66 | if rootURL != "" { |
| 67 | var err error |
| 68 | root, err = url.Parse(rootURL) |
| 69 | if err != nil { |
| 70 | return nil, err |
| 71 | } |
| 72 | if !root.IsAbs() { |
| 73 | return nil, errSchemeNotSpecified.New() |
| 74 | } |
| 75 | } |
| 76 | return httpFetcher{ |
| 77 | baseFetcher: baseFetcher{ |
| 78 | latency: fetchLatency.WithLabelValues("http", rootURL), |
| 79 | }, |
| 80 | httpClient: client, |
| 81 | root: root, |
| 82 | }, nil |
| 83 | } |