Skip to content

Commit

Permalink
Merge pull request #15 from maguoxin1234/vector1.1.7
Browse files Browse the repository at this point in the history
version1.1.7: endpoint去掉http:// 或 https:// 头信息
  • Loading branch information
maguoxin1234 authored Jul 29, 2024
2 parents 2c7f042 + 1485827 commit 6796d0e
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type Config struct {
AccessUserName *string `json:"accessUserName,omitempty" xml:"accessUserName,omitempty"`
AccessPassWord *string `json:"accessPassWord,omitempty" xml:"accessPassWord,omitempty"`
UserAgent *string `json:"userAgent,omitempty" xml:"userAgent,omitempty"`
HttpProxy *string `json:"httpProxy,omitempty" xml:"httpProxy,omitempty"`
RuntimeOptions *util.RuntimeOptions `json:"runtimeOptions,omitempty" xml:"runtimeOptions,omitempty"`
}

Expand Down Expand Up @@ -57,11 +56,6 @@ func (s *Config) SetUserAgent(v string) *Config {
return s
}

func (s *Config) SetHttpProxy(v string) *Config {
s.HttpProxy = &v
return s
}

func (s *Config) SetRuntimeOptions(v *util.RuntimeOptions) *Config {
s.RuntimeOptions = v
return s
Expand Down Expand Up @@ -445,7 +439,6 @@ type Client struct {
UserAgent *string
Credential *string
Domainsuffix *string
HttpProxy *string
RuntimeOptions *util.RuntimeOptions
}

Expand All @@ -468,12 +461,11 @@ func (client *Client)Init(config *Config)(_err error) {
client.Credential = client.GetRealmSignStr(config.AccessUserName, config.AccessPassWord)
}

client.Endpoint = config.Endpoint
client.Endpoint = client.GetEndpoint(config.Endpoint)
client.InstanceId = config.InstanceId
client.Protocol = config.Protocol
client.UserAgent = config.UserAgent
client.Domainsuffix = tea.String("ha.aliyuncs.com")
client.HttpProxy = config.HttpProxy
client.RuntimeOptions = client.BuildRuntimeOptions(config.RuntimeOptions)
return nil
}
Expand All @@ -488,7 +480,6 @@ func (client *Client) _request(method *string, pathname *string, query map[strin
"timeouted": "retry",
"readTimeout": tea.IntValue(runtime.ReadTimeout),
"connectTimeout": tea.IntValue(runtime.ConnectTimeout),
"httpProxy": tea.StringValue(runtime.HttpProxy),
"httpsProxy": tea.StringValue(runtime.HttpsProxy),
"noProxy": tea.StringValue(runtime.NoProxy),
"maxIdleConns": tea.IntValue(runtime.MaxIdleConns),
Expand Down Expand Up @@ -604,6 +595,26 @@ func (client *Client) _request(method *string, pathname *string, query map[strin
}


// Description:
//
// 如果endpoint 配置以 http:// 或 https:// 开头,则去掉头部的 http:// 或 https://, 否则直接返回
func (client *Client) GetEndpoint (endpoint *string) (_result *string) {
if tea.BoolValue(string_.HasPrefix(endpoint, tea.String("http://"))) {
_body := string_.Replace(endpoint, tea.String("http://"), tea.String(""), tea.Int(1))
_result = _body
return _result
}

if tea.BoolValue(string_.HasPrefix(endpoint, tea.String("https://"))) {
_body := string_.Replace(endpoint, tea.String("https://"), tea.String(""), tea.Int(1))
_result = _body
return _result
}

_result = endpoint
return _result
}

// Description:
//
// 设置Client UA 配置.
Expand Down

0 comments on commit 6796d0e

Please sign in to comment.