Skip to content

Commit d8ce296

Browse files
committed
docs: add doc comments to all exported functions
1 parent b50a2dd commit d8ce296

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

multiproxy.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ type Client struct {
7676
servers []*url.URL
7777
}
7878

79+
// NewClient creates a new Client with the given configuration.
80+
// It returns an error if no proxies are provided in the configuration.
7981
func NewClient(config Config) (*Client, error) {
8082
if len(config.Proxies) == 0 {
8183
return nil, errors.New("at least one proxy is required")
@@ -240,6 +242,8 @@ func (c *Client) do(req *http.Request) (*http.Response, error) {
240242
return nil, fmt.Errorf("all proxy servers failed, last error: %v", lastErr)
241243
}
242244

245+
// Do sends an HTTP request and returns an HTTP response, following policy
246+
// (such as redirects, cookies, auth) as configured on the client.
243247
func (c *Client) Do(req *http.Request) (*http.Response, error) {
244248
v, err, _ := c.sf.Do(req.URL.Host, func() (interface{}, error) {
245249
var resp *http.Response
@@ -267,6 +271,8 @@ func (c *Client) Do(req *http.Request) (*http.Response, error) {
267271
return v.(*http.Response), nil
268272
}
269273

274+
// NewRequest creates a new http.Request with the provided method, URL, and optional body.
275+
// It sets the default User-Agent if configured.
270276
func (c *Client) NewRequest(method, url string, body io.Reader) (*http.Request, error) {
271277
req, err := http.NewRequest(method, url, body)
272278
if err != nil {
@@ -281,6 +287,7 @@ func (c *Client) NewRequest(method, url string, body io.Reader) (*http.Request,
281287
return req, nil
282288
}
283289

290+
// Get issues a GET request to the specified URL.
284291
func (c *Client) Get(url string) (*http.Response, error) {
285292
req, err := c.NewRequest("GET", url, nil)
286293
if err != nil {
@@ -289,6 +296,7 @@ func (c *Client) Get(url string) (*http.Response, error) {
289296
return c.Do(req)
290297
}
291298

299+
// Post issues a POST request to the specified URL with the given content type and body.
292300
func (c *Client) Post(url, contentType string, body io.Reader) (*http.Response, error) {
293301
req, err := c.NewRequest("POST", url, body)
294302
if err != nil {
@@ -298,6 +306,7 @@ func (c *Client) Post(url, contentType string, body io.Reader) (*http.Response,
298306
return c.Do(req)
299307
}
300308

309+
// Head issues a HEAD request to the specified URL.
301310
func (c *Client) Head(url string) (*http.Response, error) {
302311
req, err := c.NewRequest("HEAD", url, nil)
303312
if err != nil {

0 commit comments

Comments
 (0)