blob: eade564afdb47211b5a0a2b2145fceddee364d6d (
plain) (
tree)
|
|
// 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")
req.Header.Set("Cache-Control", "max-age=0")
req.Header.Set("Accept", "application/geo+json")
return req
}
|