Experimental usability stage
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -40,6 +41,11 @@ func JoinURL(base string, paths ...string) (string, error) {
|
||||
return joined, nil
|
||||
}
|
||||
|
||||
var (
|
||||
once sync.Once
|
||||
instance *Client
|
||||
)
|
||||
|
||||
type ClientOption func(*Client)
|
||||
|
||||
// Client represents an HTTP client with additional capabilities
|
||||
@@ -83,6 +89,11 @@ func (c *Client) WithLogger(logger zerolog.Logger) *Client {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Client) WithTransport(transport *http.Transport) *Client {
|
||||
c.client.Transport = transport
|
||||
return c
|
||||
}
|
||||
|
||||
// WithRetryableStatus adds status codes that should trigger a retry
|
||||
func (c *Client) WithRetryableStatus(statusCodes ...int) *Client {
|
||||
for _, code := range statusCodes {
|
||||
@@ -307,3 +318,10 @@ func Gzip(body []byte) []byte {
|
||||
}
|
||||
return b.Bytes()
|
||||
}
|
||||
|
||||
func Default() *Client {
|
||||
once.Do(func() {
|
||||
instance = New()
|
||||
})
|
||||
return instance
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user