summaryrefslogtreecommitdiff
path: root/http_getter
diff options
context:
space:
mode:
Diffstat (limited to 'http_getter')
-rw-r--r--http_getter/http_getter.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/http_getter/http_getter.go b/http_getter/http_getter.go
index 5df3ac2..9fdf7a5 100644
--- a/http_getter/http_getter.go
+++ b/http_getter/http_getter.go
@@ -4,16 +4,27 @@ import (
"net/http"
)
-// Get is like http.Get, but we're sending our own user agent.
-func Get(url string) (*http.Response, error) {
- client := &http.Client{}
-
+func BuildGetRequest(url string) (*http.Request, error) {
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, err
}
req.Header.Add("User-Agent", "github.com/slivasur/startpage")
+ return req, nil
+}
+func Do(req *http.Request) (*http.Response, error) {
+ client := &http.Client{}
return client.Do(req)
}
+
+// Get is like http.Get, but we're sending our own user agent.
+func Get(url string) (*http.Response, error) {
+ req, err := BuildGetRequest(url)
+ if err != nil {
+ return nil, err
+ }
+
+ return Do(req)
+}