feat: support proxy (#284)

This commit is contained in:
Levi authored and GitHub committed 2023-12-02 18:36:52 +08:00
1 parent ef97528114
commit 16b7a3d5b3
45 files changed
+1017 -1124

No files matched your search

+14
View File
@@ -2,6 +2,7 @@ package util
import (
"encoding/base64"
"net/url"
"regexp"
"strings"
)
@@ -37,3 +38,16 @@ func ParseDataUri(uri string) (string, []byte) {
}
return mime, data
}
// BuildProxyUrl builds a proxy url with given host, username and password.
func BuildProxyUrl(scheme, host, usr, pwd string) *url.URL {
var user *url.Userinfo
if usr != "" && pwd != "" {
user = url.UserPassword(usr, pwd)
}
return &url.URL{
Scheme: scheme,
User: user,
Host: host,
}
}