From 6c777e540a9c15eea62407aa878be855a2e8e6e4 Mon Sep 17 00:00:00 2001 From: siddharth Date: Sun, 24 Apr 2022 00:05:25 -0400 Subject: http/client: flesh out Get --- http/client/client.go | 31 +++++++++++++++++++++++++++++++ http/client/http.go | 20 -------------------- 2 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 http/client/client.go delete mode 100644 http/client/http.go (limited to 'http') 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 +// 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 +} diff --git a/http/client/http.go b/http/client/http.go deleted file mode 100644 index 85bd04b..0000000 --- a/http/client/http.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright © 2022 siddharth -// SPDX-License-Identifier: ISC - -// Thin HTTP client wrapper. -package client - -import "net/http" - -// HTTP client. -var client = http.Client{} - -// Make a HTTP GET request. -func Get(url string) (resp *http.Response, err error) { - return nil, nil -} - -// Add default headers for the peach http client. -func (req *http.Request) buildHeaders() { - req.Header.Set("User-Agent", "peach/"+peach.Version+" ricketyspace.net/contact") -} -- cgit v1.2.3