mirror of
https://git.sr.ht/~adnano/go-gemini
synced 2024-11-23 16:52:06 +01:00
Don't expose DefaultClient
This commit is contained in:
parent
0d09331fc4
commit
e35e94bc82
16
gemini.go
16
gemini.go
@ -22,31 +22,25 @@ var (
|
||||
ErrInputRequired = errors.New("gemini: input required")
|
||||
)
|
||||
|
||||
// DefaultClient is the default client. It is used by Get and Do.
|
||||
//
|
||||
// On the first request, DefaultClient loads the default list of known hosts.
|
||||
var DefaultClient Client
|
||||
// defaultClient is the default client. It is used by Get and Do.
|
||||
var defaultClient Client
|
||||
|
||||
// Get performs a Gemini request for the given url.
|
||||
//
|
||||
// Get is a wrapper around DefaultClient.Get.
|
||||
func Get(url string) (*Response, error) {
|
||||
setupDefaultClientOnce()
|
||||
return DefaultClient.Get(url)
|
||||
return defaultClient.Get(url)
|
||||
}
|
||||
|
||||
// Do performs a Gemini request and returns a Gemini response.
|
||||
//
|
||||
// Do is a wrapper around DefaultClient.Do.
|
||||
func Do(req *Request) (*Response, error) {
|
||||
setupDefaultClientOnce()
|
||||
return DefaultClient.Do(req)
|
||||
return defaultClient.Do(req)
|
||||
}
|
||||
|
||||
var defaultClientOnce sync.Once
|
||||
|
||||
func setupDefaultClientOnce() {
|
||||
defaultClientOnce.Do(func() {
|
||||
DefaultClient.KnownHosts.LoadDefault()
|
||||
defaultClient.KnownHosts.LoadDefault()
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user