blob: a60ee0026755652b205d5d08b483a977861e3210 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Copyright © 2022 siddharth ravikumar <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+
" peach.ricketyspace.net")
return req
}
|