What is the alternatives of &http.transport while converting it to Elastic go client?


(Rohit Kumar Jain) #1

Hi team,

how do we implement tcp proxy using elastic go client? Any lead would be appreciated..... I have written code using http in golang... but now I want it to convert it using elastic go client...

client := &http.Client{}
ret := os.Getenv("SOCKS5_PROXY")
if (ret != "") {
log.Println("Environment variable SOCKS5_PROXY set to: " + os.Getenv("SOCKS5_PROXY"))

	// create a socks5 dialer
	dialer, err := proxy.SOCKS5("tcp", ret, nil, proxy.Direct)
	if err != nil {
		fmt.Fprintln(os.Stderr, "can't connect to the proxy:", err)
		os.Exit(1)
	}

	// setup a http client
	httpTransport := &http.Transport{}

	// set our socks5 as the dialer
	httpTransport.Dial = dialer.Dial
	client = &http.Client{Transport: httpTransport}
}

I am not able to implement same by using elastic go client...(ex: client, err := elastic.NewClient() ).. Can somebody please help me.