Browse Source

client: add KeysAPI.RGet

Brian Waldon 11 years ago
parent
commit
8b3d05f661
1 changed files with 16 additions and 0 deletions
  1. 16 0
      client/keys.go

+ 16 - 0
client/keys.go

@@ -65,6 +65,7 @@ type KeysAPI interface {
 	Update(ctx context.Context, key, value string) (*Response, error)
 	Update(ctx context.Context, key, value string) (*Response, error)
 
 
 	Get(ctx context.Context, key 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
 	Watch(key string, idx uint64) Watcher
 	RWatch(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)
 	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 {
 func (k *httpKeysAPI) Watch(key string, idx uint64) Watcher {
 	return &httpWatcher{
 	return &httpWatcher{
 		client: k.client,
 		client: k.client,