@@ -13,6 +13,7 @@ import (
1313 "time"
1414
1515 "github.com/deploymenttheory/go-api-http-client/logger"
16+ "github.com/deploymenttheory/go-api-http-client/proxy"
1617 "github.com/deploymenttheory/go-api-http-client/redirecthandler"
1718 "go.uber.org/zap"
1819)
@@ -38,6 +39,7 @@ type ClientConfig struct {
3839 Auth AuthConfig // User can either supply these values manually or pass from LoadAuthConfig/Env vars
3940 Environment EnvironmentConfig // User can either supply these values manually or pass from LoadAuthConfig/Env vars
4041 ClientOptions ClientOptions // Optional configuration options for the HTTP Client
42+ Proxy ProxyConfig // Proxy configuration options for the HTTP Client
4143}
4244
4345// AuthConfig represents the structure to read authentication details from a JSON configuration file.
@@ -72,6 +74,13 @@ type ClientOptions struct {
7274 CustomTimeout time.Duration
7375}
7476
77+ type ProxyConfig struct {
78+ ProxyURL string `json:"ProxyURL,omitempty"`
79+ ProxyUsername string `json:"ProxyUsername,omitempty"`
80+ ProxyPassword string `json:"ProxyPassword,omitempty"`
81+ ProxyAuthToken string `json:"ProxyAuthToken,omitempty"`
82+ }
83+
7584// ClientPerformanceMetrics captures various metrics related to the client's
7685// interactions with the API, providing insights into its performance and behavior.
7786type PerformanceMetrics struct {
@@ -126,6 +135,12 @@ func BuildClient(config ClientConfig) (*Client, error) {
126135 log .Error ("Failed to set up redirect handler" , zap .Error (err ))
127136 return nil , err
128137 }
138+
139+ // Conditionally Initialize the proxy if provided in the configuration
140+ if err := proxy .InitializeProxy (httpClient , config .Proxy .ProxyURL , config .Proxy .ProxyUsername , config .Proxy .ProxyPassword , config .Proxy .ProxyAuthToken , log ); err != nil {
141+ return nil , err
142+ }
143+
129144 // Create a new HTTP client with the provided configuration.
130145 client := & Client {
131146 APIHandler : apiHandler ,
0 commit comments