xkcd/client.go
jolheiser c86778321f
Initial commit
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2021-05-04 22:10:30 -05:00

30 lines
502 B
Go

package xkcd
import "net/http"
// Client is an XKCD client
type Client struct {
http *http.Client
}
// New returns a new XKCD Client
func New(opts ...ClientOption) *Client {
c := &Client{
http: http.DefaultClient,
}
for _, opt := range opts {
opt(c)
}
return c
}
// ClientOption is options for a Client
type ClientOption func(*Client)
// WithHTTP sets the http.Client for the XKCD Client
func WithHTTP(client *http.Client) ClientOption {
return func(c *Client) {
c.http = client
}
}