From 12d34c44c96c9289b67bdfbad131edf8f2cd74f8 Mon Sep 17 00:00:00 2001 From: siddharth Date: Sun, 8 May 2022 11:26:17 -0400 Subject: http/client -> client --- http/client/client.go | 30 ------------------------------ http/client/client_test.go | 22 ---------------------- 2 files changed, 52 deletions(-) delete mode 100644 http/client/client.go delete mode 100644 http/client/client_test.go (limited to 'http/client') diff --git a/http/client/client.go b/http/client/client.go deleted file mode 100644 index e5678c7..0000000 --- a/http/client/client.go +++ /dev/null @@ -1,30 +0,0 @@ -// 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 - } - 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 -} diff --git a/http/client/client_test.go b/http/client/client_test.go deleted file mode 100644 index 56a79c0..0000000 --- a/http/client/client_test.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright © 2022 siddharth -// SPDX-License-Identifier: ISC - -package client - -import ( - "io" - "testing" -) - -func TestGet(t *testing.T) { - res, err := Get("https://plan.cat/~s") - if err != nil { - t.Errorf("get failed: %v", err) - return - } - _, err = io.ReadAll(res.Body) - if err != nil { - t.Errorf("response read failed: %v", err) - return - } -} -- cgit v1.2.3