From 8b3d05f661cdda5efdca2b38940d9829936a0ea7 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 22 Jan 2015 09:57:30 -0800 Subject: [PATCH] client: add KeysAPI.RGet --- client/keys.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/keys.go b/client/keys.go index 89ef29b96..1062dfc72 100644 --- a/client/keys.go +++ b/client/keys.go @@ -65,6 +65,7 @@ type KeysAPI interface { Update(ctx context.Context, key, value string) (*Response, error) Get(ctx context.Context, key string) (*Response, error) + RGet(ctx context.Context, key string) (*Response, error) Watch(key string, idx uint64) Watcher RWatch(key string, idx uint64) Watcher @@ -154,6 +155,21 @@ func (k *httpKeysAPI) Get(ctx context.Context, key string) (*Response, error) { return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body) } +func (k *httpKeysAPI) RGet(ctx context.Context, key string) (*Response, error) { + get := &getAction{ + Prefix: k.prefix, + Key: key, + Recursive: true, + } + + resp, body, err := k.client.Do(ctx, get) + if err != nil { + return nil, err + } + + return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body) +} + func (k *httpKeysAPI) Watch(key string, idx uint64) Watcher { return &httpWatcher{ client: k.client,