@@ -19,9 +19,8 @@ import (
19
19
// Config holds configuration options for the HTTP Client.
20
20
type Config struct {
21
21
// Required
22
- InstanceName string
23
- Auth AuthConfig // User can either supply these values manually or pass from LoadAuthConfig/Env vars
24
- APIType EnvironmentConfig // User can either supply these values manually or pass from LoadAuthConfig/Env vars
22
+ Auth AuthConfig // User can either supply these values manually or pass from LoadAuthConfig/Env vars
23
+ Environment EnvironmentConfig // User can either supply these values manually or pass from LoadAuthConfig/Env vars
25
24
// Optional
26
25
LogLevel logger.LogLevel // Field for defining tiered logging level.
27
26
MaxRetryAttempts int // Config item defines the max number of retry request attempts for retryable HTTP methods.
@@ -89,19 +88,19 @@ func BuildClient(config Config) (*Client, error) {
89
88
}
90
89
91
90
// Use the APIType from the config to determine which API handler to load
92
- apiHandler , err := LoadAPIHandler (config .APIType .APIType , log )
91
+ apiHandler , err := LoadAPIHandler (config .Environment .APIType , log )
93
92
if err != nil {
94
- return nil , log .Error ("Failed to load API handler" , zap .String ("APIType" , config .APIType .APIType ), zap .Error (err ))
93
+ return nil , log .Error ("Failed to load API handler" , zap .String ("APIType" , config .Environment .APIType ), zap .Error (err ))
95
94
}
96
95
97
96
log .Info ("Initializing new HTTP client" ,
98
- zap .String ("InstanceName" , config .InstanceName ), // Using zap.String for structured logging
99
- zap .String ("APIType" , config .APIType .APIType ), // Using zap.String for structured logging
100
- zap .Int ("LogLevel" , int (config .LogLevel )), // Using zap.Int to log LogLevel as an integer
97
+ zap .String ("InstanceName" , config .Environment . APIType ), // Using zap.String for structured logging
98
+ zap .String ("APIType" , config .Environment .APIType ), // Using zap.String for structured logging
99
+ zap .Int ("LogLevel" , int (config .LogLevel )), // Using zap.Int to log LogLevel as an integer
101
100
)
102
101
103
102
// Validate and set default values for the configuration
104
- if config .InstanceName == "" {
103
+ if config .Environment . APIType == "" {
105
104
return nil , log .Error ("InstanceName cannot be empty" )
106
105
}
107
106
@@ -151,7 +150,7 @@ func BuildClient(config Config) (*Client, error) {
151
150
}
152
151
153
152
client := & Client {
154
- InstanceName : config .InstanceName ,
153
+ InstanceName : config .Environment . APIType ,
155
154
APIHandler : apiHandler ,
156
155
AuthMethod : AuthMethod ,
157
156
httpClient : & http.Client {Timeout : config .CustomTimeout },
0 commit comments