From 74130008f7d44bdf1294b833a94d5ca9bda20cd6 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Fri, 19 Feb 2016 00:20:20 +0000 Subject: [PATCH] deduplicate dialFunc --- client/http_client.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/client/http_client.go b/client/http_client.go index 100507196..d49001ed0 100644 --- a/client/http_client.go +++ b/client/http_client.go @@ -18,26 +18,21 @@ import ( // Get/Post require a dummyDomain but it's over written by the Transport var dummyDomain = "http://dummyDomain/" -func unixDial(remote string) func(string, string) (net.Conn, error) { +func dialFunc(sockType, remote string) func(string, string) (net.Conn, error) { return func(proto, addr string) (conn net.Conn, err error) { - return net.Dial("unix", remote) - } -} - -func tcpDial(remote string) func(string, string) (net.Conn, error) { - return func(proto, addr string) (conn net.Conn, err error) { - return net.Dial("tcp", remote) + return net.Dial(sockType, remote) } } +// remote is IP:PORT or /path/to/socket func socketTransport(remote string) *http.Transport { if rpctypes.SocketType(remote) == "unix" { return &http.Transport{ - Dial: unixDial(remote), + Dial: dialFunc("unix", remote), } } else { return &http.Transport{ - Dial: tcpDial(remote), + Dial: dialFunc("tcp", remote), } } }