-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrequest.go
More file actions
49 lines (44 loc) · 799 Bytes
/
Copy pathrequest.go
File metadata and controls
49 lines (44 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package fluidcurrency
import (
"io/ioutil"
"net/http"
"time"
)
// type request interface {
// Get(URL string) ([]byte, error)
// }
//
// func newRequest() request {
// return newHTTPRequest()
// }
//
// type httpRequest struct {
// netClient *http.Client
// }
//
// func newHTTPRequest() *httpRequest {
// client := &http.Client{
// Timeout: time.Second * 10,
// }
// return &httpRequest{
// netClient: client,
// }
// }
// Get main get function with a url
func Get(URL string) ([]byte, error) {
client := &http.Client{
Timeout: time.Second * 10,
}
// return &httpRequest{
// netClient: client,
// }
response, err := client.Get(URL)
if err != nil {
return nil, err
}
buf, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
return buf, nil
}