Stop parsing proxy address (#1619)
This commit is contained in:
parent
762a5bc9e8
commit
116cc1e9ee
@ -83,20 +83,23 @@ func Listen(addr string, fn func(string) (net.Listener, error)) (net.Listener, e
|
||||
func Proxy(service string, address []string) (string, []string, bool) {
|
||||
var hasProxy bool
|
||||
|
||||
// get proxy
|
||||
// get proxy. we parse out address if present
|
||||
if prx := os.Getenv("MICRO_PROXY"); len(prx) > 0 {
|
||||
// default name
|
||||
if prx == "service" {
|
||||
prx = "go.micro.proxy"
|
||||
address = nil
|
||||
}
|
||||
|
||||
// check if its an address
|
||||
if v := strings.Split(prx, ":"); len(v) > 1 {
|
||||
address = []string{prx}
|
||||
}
|
||||
|
||||
service = prx
|
||||
hasProxy = true
|
||||
}
|
||||
|
||||
// get proxy address
|
||||
if prx := os.Getenv("MICRO_PROXY_ADDRESS"); len(prx) > 0 {
|
||||
address = []string{prx}
|
||||
hasProxy = true
|
||||
return service, address, hasProxy
|
||||
}
|
||||
|
||||
if prx := os.Getenv("MICRO_NETWORK"); len(prx) > 0 {
|
||||
|
@ -57,7 +57,6 @@ func TestProxyEnv(t *testing.T) {
|
||||
}
|
||||
|
||||
test("MICRO_PROXY", "service", "go.micro.proxy", "")
|
||||
test("MICRO_PROXY_ADDRESS", "10.0.0.1:8080", "", "10.0.0.1:8080")
|
||||
test("MICRO_NETWORK", "service", "go.micro.network", "")
|
||||
test("MICRO_NETWORK_ADDRESS", "10.0.0.1:8081", "", "10.0.0.1:8081")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user