This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
go-discogs/discogs.go

34 lines
699 B
Go
Raw Normal View History

2016-03-04 16:08:02 +00:00
package discogs
import (
"github.com/irlndts/go-apirequest"
"net/http"
)
const (
discogsAPI = "https://api.discogs.com/"
2016-03-09 14:54:25 +00:00
useragent = "Test UserAgent"
2016-03-04 16:08:02 +00:00
)
// Client is a Discogs client for making Discogs API requests.
type Client struct {
2016-03-04 16:48:26 +00:00
api *apirequest.API
Release *ReleaseService
2016-03-04 16:08:02 +00:00
}
// NewClient returns a new Client.
func NewClient(httpClient *http.Client) *Client {
base := apirequest.New().Client(httpClient).Base(discogsAPI).Add("User-Agent", useragent)
return &Client{
2016-03-04 16:48:26 +00:00
api: base,
Release: newReleaseService(base.New()),
2016-03-04 16:08:02 +00:00
}
}
2016-03-09 14:54:25 +00:00
// discogs require specified user agent
func (c *Client) UserAgent(useragent string) *Client {
c.api.Set("User-Agent", useragent)
return c
}