diff --git a/chord/httpnode/client.go b/chord/httpnode/client.go index 4aaf542..f5962d0 100644 --- a/chord/httpnode/client.go +++ b/chord/httpnode/client.go @@ -25,10 +25,9 @@ func (cl *Client) Find(ctx context.Context, s chord.Peer, id chord.ID) (chord.Pe return chord.Peer{}, "", errors.New("Find with invalid peer") } url := url.URL{ - Scheme: "http", - Host: addr.String(), - Path: path.Join("/", cl.APIBase, "key"), - RawQuery: url.Values{"s": {id.String()}}.Encode(), + Scheme: "http", + Host: addr.String(), + Path: path.Join("/", cl.APIBase, "key", id.String()), } req, err := http.NewRequestWithContext(ctx, "GET", url.String(), nil) if err != nil { diff --git a/chord/httpnode/server.go b/chord/httpnode/server.go index 891dae7..944cb73 100644 --- a/chord/httpnode/server.go +++ b/chord/httpnode/server.go @@ -45,7 +45,7 @@ func New(l net.Listener, cl chord.Client) (*Node, error) { // Router creates a handler for the Chord HTTP endpoints. func (n *Node) Router() http.Handler { m := http.NewServeMux() - m.HandleFunc("GET /key", n.key) + m.HandleFunc("GET /key/{id}", n.key) m.HandleFunc("POST /pred", n.notify) m.HandleFunc("GET /neighbors", n.neighbors) return m @@ -66,7 +66,7 @@ func (n *Node) Check(ctx context.Context) error { } func (n *Node) key(w http.ResponseWriter, r *http.Request) { - s := r.FormValue("s") + s := r.PathValue("id") id, err := chord.ParseID(s) if err != nil { writeError(w, http.StatusBadRequest, err.Error())