Skip to content

Commit 88da6eb

Browse files
tongyimingmikatong
andauthored
feat: support set ReqClient from env (#1354)
Co-authored-by: mikatong <mikatong@tencent.com>
1 parent 65bca2e commit 88da6eb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tencentcloud/connectivity/transport.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ import (
77
"io/ioutil"
88
"log"
99
"net/http"
10+
"os"
1011
"time"
1112
)
1213

14+
const REQUEST_CLIENT = "TENCENTCLOUD_API_REQUEST_CLIENT"
15+
1316
var ReqClient = "Terraform-latest"
1417

1518
func SetReqClient(name string) {
@@ -35,6 +38,11 @@ func (me *LogRoundTripper) RoundTrip(request *http.Request) (response *http.Resp
3538
return
3639
}
3740
var headName = "X-TC-Action"
41+
42+
if envReqClient := os.Getenv(REQUEST_CLIENT); envReqClient != "" {
43+
ReqClient = envReqClient
44+
}
45+
3846
request.Header.Set("X-TC-RequestClient", ReqClient)
3947
inBytes = []byte(fmt.Sprintf("%s, request: ", request.Header[headName]))
4048
requestBody, errRet := ioutil.ReadAll(bodyReader)

0 commit comments

Comments
 (0)