summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2021-11-27 18:56:22 -0500
committersiddharth <s@ricketyspace.net>2021-11-27 18:56:54 -0500
commit6da48b8b76eec5864510b6cdbeb5398a5ca3ce97 (patch)
tree7765471aed876737b61554effd61cc1cd7ad50ca
parenta67509becdba97c3d467d17e73959c58ade5772a (diff)
feed: add `get`
HTTP GETs raw feed from Feed.Source
-rw-r--r--feed/feed.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/feed/feed.go b/feed/feed.go
index cf4526b..109de5e 100644
--- a/feed/feed.go
+++ b/feed/feed.go
@@ -5,6 +5,8 @@ package feed
import (
"fmt"
+ "io"
+ "net/http"
"os"
"path"
)
@@ -54,3 +56,29 @@ func (feed *Feed) Validate(baseDumpDir string) error {
return nil
}
+
+// Get the feed.
+func (feed *Feed) get() ([]byte, error) {
+ // Init byte container to store feed content.
+ bs := make([]byte, 0)
+
+ resp, err := http.Get(feed.Source)
+ if err != nil {
+ return bs, err
+ }
+
+ // Slurp body.
+ chunk := make([]byte, 100)
+ for {
+ c, err := resp.Body.Read(chunk)
+ if c < 1 {
+ break
+ }
+ if err != nil && err != io.EOF {
+ return bs, err
+ }
+ bs = append(bs, chunk[0:c]...)
+ }
+ return bs, nil
+}
+