remove weaveapi.NewClientWithResolver cruft
This commit is contained in:
1 parent
ae725e333a
commit
cf24bb0e89
1 file changed
+1
-14
+1
-14
@@ -19,19 +19,10 @@ const (
|
|||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
baseURL string
|
baseURL string
|
||||||
resolve func() (string, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) httpVerb(verb string, url string, values url.Values) (string, error) {
|
func (client *Client) httpVerb(verb string, url string, values url.Values) (string, error) {
|
||||||
baseURL := client.baseURL
|
url = client.baseURL + url
|
||||||
if client.resolve != nil {
|
|
||||||
addr, err := client.resolve()
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
baseURL = fmt.Sprintf("http://%s:%d", addr, WeaveHTTPPort)
|
|
||||||
}
|
|
||||||
url = baseURL + url
|
|
||||||
Log.Debugf("weave %s to %s with %v", verb, url, values)
|
Log.Debugf("weave %s to %s with %v", verb, url, values)
|
||||||
var body io.Reader
|
var body io.Reader
|
||||||
if values != nil {
|
if values != nil {
|
||||||
@@ -81,10 +72,6 @@ func NewClient(addr string) *Client {
|
|||||||
return &Client{baseURL: fmt.Sprintf("http://%s:%s", host, port)}
|
return &Client{baseURL: fmt.Sprintf("http://%s:%s", host, port)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClientWithResolver(resolver func() (string, error)) *Client {
|
|
||||||
return &Client{resolve: resolver}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) Connect(remote string) error {
|
func (client *Client) Connect(remote string) error {
|
||||||
_, err := client.httpVerb("POST", "/connect", url.Values{"peer": {remote}})
|
_, err := client.httpVerb("POST", "/connect", url.Values{"peer": {remote}})
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in new issue
Block a user