Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you add proxy and timeout for API? #10

Open
nifflin opened this issue Aug 15, 2019 · 1 comment
Open

Can you add proxy and timeout for API? #10

nifflin opened this issue Aug 15, 2019 · 1 comment

Comments

@nifflin
Copy link

nifflin commented Aug 15, 2019

like NewQuoteFromYahoo, proxy and timeout parameter is useful when concurrent data downloading. Thank you.

func SetProxy(client *http.Client, proxyUrlString string) error {
	if proxyUrlString == "" {
		return nil
	}
	ui_proxy, err := url.Parse(proxyUrlString)
	if err != nil {
		return err
	}
	transport := http.DefaultTransport.(*http.Transport)
	if client.Transport != nil {
		transport = client.Transport.(*http.Transport)
	}
	transport.Proxy = http.ProxyURL(ui_proxy)
	client.Transport = transport
	return nil
}

func SetTimeout(client *http.Client, to time.Duration) {
	client.Timeout = to
}
@markcheno
Copy link
Owner

Seems like it would be useful, but I am quite busy with other things at the moment. I will put it in my list. Pull requests welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants