platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
19
selective-vpn-api/app/egressutil/probe.go
Normal file
19
selective-vpn-api/app/egressutil/probe.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package egressutil
|
||||
|
||||
func ProbeFirstSuccess(endpoints []string, probe func(rawURL string) (string, error)) (string, []string) {
|
||||
if len(endpoints) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
errs := make([]string, 0, len(endpoints))
|
||||
for _, rawURL := range endpoints {
|
||||
if probe == nil {
|
||||
continue
|
||||
}
|
||||
val, err := probe(rawURL)
|
||||
if err == nil {
|
||||
return val, nil
|
||||
}
|
||||
errs = append(errs, err.Error())
|
||||
}
|
||||
return "", errs
|
||||
}
|
||||
Reference in New Issue
Block a user