summaryrefslogtreecommitdiffstats
path: root/client/client.go
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2022-05-08 11:26:17 -0400
committersiddharth <s@ricketyspace.net>2022-05-08 11:26:17 -0400
commit12d34c44c96c9289b67bdfbad131edf8f2cd74f8 (patch)
tree0dd225c103feaebab09c81086d834aed1ff38469 /client/client.go
parent0ffe26f6e81adbf1c2297a5f19d3350fec6a45b2 (diff)
http/client -> client
Diffstat (limited to 'client/client.go')
-rw-r--r--client/client.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/client/client.go b/client/client.go
new file mode 100644
index 0000000..e5678c7
--- /dev/null
+++ b/client/client.go
@@ -0,0 +1,30 @@
+// 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
+ }
+ return client.Do(buildHeaders(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/peach")
+ return req
+}