summaryrefslogtreecommitdiffstats
path: root/http/client/client.go
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2022-04-24 00:05:25 -0400
committersiddharth <s@ricketyspace.net>2022-04-24 00:05:25 -0400
commit6c777e540a9c15eea62407aa878be855a2e8e6e4 (patch)
tree4baca2fc2796f1cf60da92894a3004fae24a2ba7 /http/client/client.go
parent8695bc627863c0e5faa73ff8f43435c6e735f6ae (diff)
http/client: flesh out Get
Diffstat (limited to 'http/client/client.go')
-rw-r--r--http/client/client.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/http/client/client.go b/http/client/client.go
new file mode 100644
index 0000000..b57308d
--- /dev/null
+++ b/http/client/client.go
@@ -0,0 +1,31 @@
+// Copyright © 2022 siddharth <s@ricketyspace.net>
+// SPDX-License-Identifier: ISC
+
+// Thin HTTP client wrapper.
+package client
+
+import (
+ "net/http"
+
+ "ricketyspace.net/peach/version"
+)
+
+// HTTP client.
+var client = http.Client{}
+
+// Make a HTTP GET request.
+func Get(url string) (*http.Response, error) {
+ req, err := http.NewRequest("GET", url, nil)
+ if err != nil {
+ return nil, err
+ }
+ req = buildHeaders(req)
+
+ return client.Do(req)
+}
+
+// Add default headers for the peach http client.
+func buildHeaders(req *http.Request) *http.Request {
+ req.Header.Set("User-Agent", "peach/"+version.Version+" ricketyspace.net/contact")
+ return req
+}