-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
35 lines (29 loc) · 978 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package proxier
import (
"net/http"
"time"
)
const (
timeout = 30 * time.Second
useragent = `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36`
)
var (
httpRoundTripper = http.DefaultTransport.(*http.Transport).Clone()
client = &http.Client{}
)
// The Client struct wraps an http.Client and provides a higher-level interface
// for making HTTP requests. It can be used to customize the behavior of the
// client, such as specify timeouts.
type Client struct {
*http.Client
}
// NewClient returns a new instance of the Client struct with the specified
// HTTP client. If no client is provided as an argument, a default client with
// a default timeout value is created. This function is a constructor method
// and returns a pointer to the new Client instance.
func NewClient(client *http.Client) *Client {
if client == nil {
client = &http.Client{Timeout: timeout}
}
return &Client{client}
}