diff --git a/api/dns.go b/api/dns.go index 750c34f2..36ec8630 100644 --- a/api/dns.go +++ b/api/dns.go @@ -8,11 +8,11 @@ import ( func (client *Client) RegisterWithDNS(ID string, fqdn string, ip string) error { data := url.Values{} data.Add("fqdn", fqdn) - _, err := httpVerb("PUT", fmt.Sprintf("%s/name/%s/%s", client.baseUrl, ID, ip), data) + _, err := client.httpVerb("PUT", fmt.Sprintf("/name/%s/%s", ID, ip), data) return err } func (client *Client) DeregisterWithDNS(ID string, ip string) error { - _, err := httpVerb("DELETE", fmt.Sprintf("%s/name/%s/%s", client.baseUrl, ID, ip), nil) + _, err := client.httpVerb("DELETE", fmt.Sprintf("/name/%s/%s", ID, ip), nil) return err } diff --git a/api/ipam.go b/api/ipam.go index 00467dc9..8be57b27 100644 --- a/api/ipam.go +++ b/api/ipam.go @@ -6,7 +6,7 @@ import ( ) func (client *Client) ipamOp(ID string, op string) (*net.IPNet, error) { - ip, err := httpVerb(op, fmt.Sprintf("%s/ip/%s", client.baseUrl, ID), nil) + ip, err := client.httpVerb(op, fmt.Sprintf("/ip/%s", ID), nil) if err != nil { return nil, err } @@ -31,7 +31,7 @@ func (client *Client) ReleaseIP(ID string) error { } func (client *Client) DefaultSubnet() (*net.IPNet, error) { - cidr, err := httpVerb("GET", fmt.Sprintf("%s/ipinfo/defaultsubnet", client.baseUrl), nil) + cidr, err := client.httpVerb("GET", fmt.Sprintf("/ipinfo/defaultsubnet"), nil) if err != nil { return nil, err } diff --git a/api/weaveapi.go b/api/weaveapi.go index d75394bd..fd4c0320 100644 --- a/api/weaveapi.go +++ b/api/weaveapi.go @@ -20,7 +20,8 @@ type Client struct { baseUrl string } -func httpVerb(verb string, url string, values url.Values) (string, error) { +func (client *Client) httpVerb(verb string, url string, values url.Values) (string, error) { + url = client.baseUrl + url Log.Debugf("weave %s to %s with %v", verb, url, values) var body io.Reader if values != nil { @@ -54,6 +55,6 @@ func NewClient(addr string) *Client { } func (client *Client) Connect(remote string) error { - _, err := httpVerb("POST", client.baseUrl+"/connect", url.Values{"peer": {remote}}) + _, err := client.httpVerb("POST", "/connect", url.Values{"peer": {remote}}) return err }