diff --git a/util/net/net.go b/util/net/net.go index 00230647..02d6ad2f 100644 --- a/util/net/net.go +++ b/util/net/net.go @@ -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 { diff --git a/util/net/net_test.go b/util/net/net_test.go index 85688c36..28d490d4 100644 --- a/util/net/net_test.go +++ b/util/net/net_test.go @@ -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") }