diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/fetch/fetch.go | 6 | ||||
| -rw-r--r-- | internal/fetch/fetch_test.go | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/internal/fetch/fetch.go b/internal/fetch/fetch.go index f508922..f22139d 100644 --- a/internal/fetch/fetch.go +++ b/internal/fetch/fetch.go @@ -8,7 +8,11 @@ import ( "time" ) -func fetch(rawURL string, timeoutSecs int) (io.Reader, error) { +// Fetch makes a GET request to rawURL, returning the HTML contents of +// that webpage in the form of an [io.Reader]. An error is also +// returned. The parameter timeoutSecs is passed directly to the +// [http.Client.Timeout] field of the client making the request. +func Fetch(rawURL string, timeoutSecs int) (io.Reader, error) { client := http.Client{ Timeout: time.Duration(timeoutSecs) * time.Second, } diff --git a/internal/fetch/fetch_test.go b/internal/fetch/fetch_test.go index 427406d..227ba0d 100644 --- a/internal/fetch/fetch_test.go +++ b/internal/fetch/fetch_test.go @@ -3,7 +3,7 @@ package fetch import "testing" func TestFetch(t *testing.T) { - _, err := fetch("http://example.com", 2) + _, err := Fetch("http://example.com", 2) if err != nil { t.Error(err) } |
