tmp
This commit is contained in:
parent
5c75cd32bb
commit
7885a06b95
30
discogs.go
Normal file
30
discogs.go
Normal file
@ -0,0 +1,30 @@
|
||||
package discogs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/irlndts/go-apirequest"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
discogsAPI = "https://api.discogs.com/"
|
||||
useragent = "TestDiscogsClient/0.0.1 +http://irlndts.moscow"
|
||||
)
|
||||
|
||||
// Client is a Discogs client for making Discogs API requests.
|
||||
type Client struct {
|
||||
api *apirequest.API
|
||||
Releases *ReleaseService
|
||||
}
|
||||
|
||||
// NewClient returns a new Client.
|
||||
func NewClient(httpClient *http.Client) *Client {
|
||||
base := apirequest.New().Client(httpClient).Base(discogsAPI).Add("User-Agent", useragent)
|
||||
|
||||
fmt.Println(base)
|
||||
|
||||
return &Client{
|
||||
api: base,
|
||||
Releases: newReleaseService(base.New()),
|
||||
}
|
||||
}
|
14
examples/discogs_example.go
Normal file
14
examples/discogs_example.go
Normal file
@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/irlndts/go-discogs/discogs"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
client := &http.Client{}
|
||||
discogs := discogs.NewClient(client)
|
||||
fmt.Println(discogs)
|
||||
|
||||
}
|
15
releases.go
Normal file
15
releases.go
Normal file
@ -0,0 +1,15 @@
|
||||
package discogs
|
||||
|
||||
import (
|
||||
"github.com/irlndts/go-apirequest"
|
||||
)
|
||||
|
||||
type ReleaseService struct {
|
||||
api *apirequest.API
|
||||
}
|
||||
|
||||
func newReleaseService(api *apirequest.API) *ReleaseService {
|
||||
return &ReleaseService{
|
||||
api: api.Path("releases/"),
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user