support setting proxy to request exchange rates or map data

This commit is contained in:
MaysWind
2024-03-03 11:46:30 +08:00
parent 3fc2a763b4
commit fa4a17f47b
5 changed files with 39 additions and 2 deletions
+18
View File
@@ -0,0 +1,18 @@
package utils
import (
"net/http"
"net/url"
)
// SetProxyUrl sets proxy url to http transport according to specified proxy setting
func SetProxyUrl(transport *http.Transport, proxy string) {
if proxy == "none" {
transport.Proxy = nil
} else if proxy != "system" {
proxy, _ := url.Parse(proxy)
transport.Proxy = http.ProxyURL(proxy)
} else {
transport.Proxy = http.ProxyFromEnvironment
}
}