Add a cached http client

This commit is contained in:
Deluan
2021-02-07 23:26:05 -05:00
committed by Deluan Quintão
parent 9d24106066
commit 28cdf1e693
11 changed files with 234 additions and 14 deletions
+3 -3
View File
@@ -14,18 +14,18 @@ const (
apiBaseUrl = "https://ws.audioscrobbler.com/2.0/"
)
type HttpClient interface {
type httpDoer interface {
Do(req *http.Request) (*http.Response, error)
}
func NewClient(apiKey string, lang string, hc HttpClient) *Client {
func NewClient(apiKey string, lang string, hc httpDoer) *Client {
return &Client{apiKey, lang, hc}
}
type Client struct {
apiKey string
lang string
hc HttpClient
hc httpDoer
}
func (c *Client) makeRequest(params url.Values) (*Response, error) {