diff --git a/chord/httpnode/client.go b/chord/httpnode/client.go index c81062f..7a4a365 100644 --- a/chord/httpnode/client.go +++ b/chord/httpnode/client.go @@ -21,8 +21,6 @@ import ( type Client struct { // HTTP is the client used to make requests. HTTP http.Client - // APIBase is the path under which the Chord API is served. - APIBase string } // FindSuccessor asks s to find a value and the peer that owns it. @@ -34,7 +32,7 @@ func (cl *Client) FindSuccessor(ctx context.Context, s chord.Peer, id chord.ID) url := url.URL{ Scheme: "http", Host: addr.String(), - Path: path.Join("/", cl.APIBase, "find", id.String()), + Path: path.Join("/find", id.String()), } req, err := http.NewRequestWithContext(ctx, "GET", url.String(), nil) if err != nil { @@ -58,7 +56,7 @@ func (cl *Client) Get(ctx context.Context, s chord.Peer, id chord.ID) (string, e url := url.URL{ Scheme: "http", Host: addr.String(), - Path: path.Join("/", cl.APIBase, "key", id.String()), + Path: path.Join("/key", id.String()), } req, err := http.NewRequestWithContext(ctx, "GET", url.String(), nil) if err != nil { @@ -84,7 +82,7 @@ func (cl *Client) Set(ctx context.Context, s chord.Peer, id chord.ID, v string) url := url.URL{ Scheme: "http", Host: addr.String(), - Path: path.Join("/", cl.APIBase, "key", id.String()), + Path: path.Join("/key", id.String()), } body := strings.NewReader(base64.StdEncoding.EncodeToString([]byte(v))) req, err := http.NewRequestWithContext(ctx, "POST", url.String(), body) @@ -112,7 +110,7 @@ func (cl *Client) Notify(ctx context.Context, n *chord.Node, s chord.Peer) error url := url.URL{ Scheme: "http", Host: addr.String(), - Path: path.Join("/", cl.APIBase, "pred"), + Path: path.Join("/pred"), RawQuery: url.Values{"p": {self.String()}}.Encode(), } req, err := http.NewRequestWithContext(ctx, "POST", url.String(), nil) @@ -139,7 +137,7 @@ func (cl *Client) Neighbors(ctx context.Context, p chord.Peer) (pred chord.Peer, url := url.URL{ Scheme: "http", Host: addr.String(), - Path: path.Join("/", cl.APIBase, "neighbors"), + Path: path.Join("/neighbors"), } req, err := http.NewRequestWithContext(ctx, "GET", url.String(), nil) if err != nil { @@ -188,7 +186,7 @@ func (cl *Client) Bye(ctx context.Context, p, n chord.Peer, succ []chord.Peer) e url := url.URL{ Scheme: "http", Host: addr.String(), - Path: path.Join("/", cl.APIBase, "bye"), + Path: path.Join("/bye"), } req, err := http.NewRequestWithContext(ctx, "POST", url.String(), bytes.NewReader(b)) if err != nil { @@ -214,7 +212,7 @@ func (cl *Client) SayBye(ctx context.Context, p chord.Peer) error { url := url.URL{ Scheme: "http", Host: addr.String(), - Path: path.Join("/", cl.APIBase), + Path: path.Join("/"), } req, err := http.NewRequestWithContext(ctx, "DELETE", url.String(), nil) if err != nil {