Skip to content

Commit 197c6ff

Browse files
authored
docs: add proxy and SOCKS5 support to HTTP client configuration (#214)
- Add proxy, socks, and skip verify options to the Anthropic client configuration - Introduce `DefaultHeaderTransport` for adding headers to HTTP requests - Implement HTTP client setup with optional proxy and SOCKS5 support - Add new options `WithProxyURL`, `WithSocksURL`, and `WithSkipVerify` for client configuration Signed-off-by: appleboy <[email protected]>
1 parent b9d7f8a commit 197c6ff

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

provider/anthropic/anthropic.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,19 @@ func (t *DefaultHeaderTransport) RoundTrip(req *http.Request) (*http.Response, e
116116
return t.Origin.RoundTrip(req)
117117
}
118118

119+
// New creates a new Client instance with the provided options.
120+
// It validates the configuration, sets up the HTTP transport with optional
121+
// proxy settings, and initializes the Client with the specified parameters.
122+
//
123+
// Parameters:
124+
//
125+
// opts - A variadic list of Option functions to configure the Client.
126+
//
127+
// Returns:
128+
//
129+
// c - A pointer to the newly created Client instance.
130+
// err - An error if the configuration is invalid or if there is an issue
131+
// setting up the HTTP transport or proxy.
119132
func New(opts ...Option) (c *Client, err error) {
120133
// Create a new config object with the given options.
121134
cfg := newConfig(opts...)
@@ -148,10 +161,7 @@ func New(opts ...Option) (c *Client, err error) {
148161
tr.DialContext = dialer.(proxy.ContextDialer).DialContext
149162
}
150163

151-
// Set the HTTP client to use the default header transport with the specified headers.
152-
httpClient.Transport = &DefaultHeaderTransport{
153-
Origin: tr,
154-
}
164+
httpClient.Transport = tr
155165

156166
// Create a new client instance with the necessary fields.
157167
engine := &Client{

0 commit comments

Comments
 (0)