mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
general: add global setting interface
This commit is contained in:
1 parent
edd5964a1e
commit
8daa7784b0
8 files changed
+45
-26
No files matched your search
+5
-4
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user