general: add global setting interface

This commit is contained in:
nadoo committed 2018-08-20 22:23:00 +08:00
1 parent edd5964a1e
commit 8daa7784b0
8 files changed
+45 -26

No files matched your search

+5 -4
View File
@@ -37,17 +37,18 @@ func RegisterDialer(name string, c DialerCreator) {
}
// DialerFromURL calls the registered creator to create dialers.
// dialer is the default upstream dialer so cannot be nil, we can use Default when calling this function.
func DialerFromURL(s string, dialer Dialer) (Dialer, error) {
if dialer == nil {
return nil, errors.New("DialerFromURL: dialer cannot be nil")
}
u, err := url.Parse(s)
if err != nil {
log.F("parse err: %s", err)
return nil, err
}
if dialer == nil {
dialer = Default
}
c, ok := dialerMap[strings.ToLower(u.Scheme)]
if ok {
return c(s, dialer)