summaryrefslogtreecommitdiffstats
path: root/bridge/helper/helper.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-11-04 14:55:25 +0100
committerWim <wim@42.be>2017-11-04 14:55:25 +0100
commitba5649d2597c6d89f4c609d1246837f0172a722b (patch)
tree338221366e299c0902f4561eaeceaf6af57b6394 /bridge/helper/helper.go
parent1b305755100ded598dc416523a0d8813c76c5819 (diff)
downloadmatterbridge-msglm-ba5649d2597c6d89f4c609d1246837f0172a722b.tar.gz
matterbridge-msglm-ba5649d2597c6d89f4c609d1246837f0172a722b.tar.bz2
matterbridge-msglm-ba5649d2597c6d89f4c609d1246837f0172a722b.zip
Add helper
Diffstat (limited to 'bridge/helper/helper.go')
-rw-r--r--bridge/helper/helper.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go
new file mode 100644
index 00000000..ecfc4df2
--- /dev/null
+++ b/bridge/helper/helper.go
@@ -0,0 +1,28 @@
+package helper
+
+import (
+ "bytes"
+ "io"
+ "net/http"
+ "time"
+)
+
+func DownloadFile(url string) (*[]byte, error) {
+ var buf bytes.Buffer
+ client := &http.Client{
+ Timeout: time.Second * 5,
+ }
+ req, err := http.NewRequest("GET", url, nil)
+ if err != nil {
+ return nil, err
+ }
+ resp, err := client.Do(req)
+ if err != nil {
+ resp.Body.Close()
+ return nil, err
+ }
+ io.Copy(&buf, resp.Body)
+ data := buf.Bytes()
+ resp.Body.Close()
+ return &data, nil
+}