Skip to content

Can you add proxy and timeout for API? #10

@nifflin

Description

@nifflin

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions