diff options
Diffstat (limited to 'internal/links')
| -rw-r--r-- | internal/links/fetch.go | 32 | ||||
| -rw-r--r-- | internal/links/fetch_test.go | 10 |
2 files changed, 0 insertions, 42 deletions
diff --git a/internal/links/fetch.go b/internal/links/fetch.go deleted file mode 100644 index 53cc692..0000000 --- a/internal/links/fetch.go +++ /dev/null @@ -1,32 +0,0 @@ -package links - -import ( - "bufio" - "fmt" - "io" - "net/http" - "time" -) - -func fetch(rawURL string, timeoutSecs int) (io.Reader, error) { - client := http.Client{ - Timeout: time.Duration(timeoutSecs) * time.Second, - } - - req, err := http.NewRequest(http.MethodGet, rawURL, nil) - if err != nil { - return nil, fmt.Errorf("can't create %s request for %s", http.MethodGet, rawURL) - } - - resp, err := client.Do(req) - if err != nil { - return nil, fmt.Errorf("client failed to perform %s request for %s", http.MethodGet, rawURL) - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("status for %s for %s: %s", http.MethodGet, rawURL, resp.Status) - } - - return bufio.NewReader(resp.Body), nil -} diff --git a/internal/links/fetch_test.go b/internal/links/fetch_test.go deleted file mode 100644 index 5d873a6..0000000 --- a/internal/links/fetch_test.go +++ /dev/null @@ -1,10 +0,0 @@ -package links - -import "testing" - -func TestFetch(t *testing.T) { - _, err := fetch("http://example.com", 2) - if err != nil { - t.Error(err) - } -} |
