Use strings for URLs internally for consistency.

This commit is contained in:
nytpu
2021-03-18 13:02:17 -06:00
parent 794b1fc04f
commit f8601b82ab
5 changed files with 33 additions and 34 deletions
+5 -6
View File
@@ -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