diff options
| author | nytpu <alex@nytpu.com> | 2021-03-18 13:02:17 -0600 |
|---|---|---|
| committer | nytpu <alex@nytpu.com> | 2021-03-18 13:02:17 -0600 |
| commit | f8601b82abe77e19fbe0c97a21f00540da39ac9f (patch) | |
| tree | 0855e50f31d8997e10d8e6580939a902648d6ea6 /fetch/http.go | |
| parent | 794b1fc04f350c4977c873e42752ccc0ecd0a98c (diff) | |
Use strings for URLs internally for consistency.
Diffstat (limited to 'fetch/http.go')
| -rw-r--r-- | fetch/http.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/fetch/http.go b/fetch/http.go index 09d5216..2661438 100644 --- a/fetch/http.go +++ b/fetch/http.go @@ -16,7 +16,6 @@ import ( "fmt" "io" "net/http" - "net/url" "time" "github.com/mmcdole/gofeed" @@ -25,12 +24,12 @@ import ( ) // fetchHTTP will make a request for an http resource -func fetchHTTP(remoteURL *url.URL) (*http.Response, error) { +func fetchHTTP(remoteURL string) (*http.Response, error) { client := &http.Client{ Timeout: 10 * time.Second, } - req, err := http.NewRequestWithContext(context.Background(), "GET", remoteURL.String(), nil) + req, err := http.NewRequestWithContext(context.Background(), "GET", remoteURL, nil) req.Header.Add("User-Agent", "comitium (https://git.nytpu.com/comitium/)") if err != nil { return nil, err @@ -50,7 +49,7 @@ func fetchHTTP(remoteURL *url.URL) (*http.Response, error) { // httpFeed will fetch and insert a new core.Feed into a core.FullData given an // http url (or update if it's preexisting) -func httpFeed(data *core.FullData, remote *url.URL, title string) error { +func httpFeed(data *core.FullData, remote string, title string) error { resp, err := fetchHTTP(remote) if err != nil { return err @@ -78,7 +77,7 @@ func httpFeed(data *core.FullData, remote *url.URL, title string) error { // httpPage will fetch and insert a new core.Page into a core.FullData given an // http url (or update if it's preexisting) -func httpPage(data *core.FullData, remote *url.URL, title string) error { +func httpPage(data *core.FullData, remote string, title string) error { resp, err := fetchHTTP(remote) if err != nil { return err @@ -89,7 +88,7 @@ func httpPage(data *core.FullData, remote *url.URL, title string) error { var page core.Page page.Title = title - page.Link = remote.String() + page.Link = remote h := sha256.New() if _, err := io.Copy(h, reader); err != nil { return err |
