From 07eeef6f1ff86e14012d00d1fbea7d3ac0e3cb10 Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Sat, 5 Nov 2016 00:55:10 -0400 Subject: [PATCH] Trim leading slash on key to avoid redirect (golang/go#4800) (#2476) --- api/kv.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/kv.go b/api/kv.go index 5262243a1..867592490 100644 --- a/api/kv.go +++ b/api/kv.go @@ -156,7 +156,7 @@ func (k *KV) Keys(prefix, separator string, q *QueryOptions) ([]string, *QueryMe } func (k *KV) getInternal(key string, params map[string]string, q *QueryOptions) (*http.Response, *QueryMeta, error) { - r := k.c.newRequest("GET", "/v1/kv/"+key) + r := k.c.newRequest("GET", "/v1/kv/"+strings.TrimPrefix(key, "/")) r.setQueryOptions(q) for param, val := range params { r.params.Set(param, val) @@ -277,7 +277,7 @@ func (k *KV) DeleteTree(prefix string, w *WriteOptions) (*WriteMeta, error) { } func (k *KV) deleteInternal(key string, params map[string]string, q *WriteOptions) (bool, *WriteMeta, error) { - r := k.c.newRequest("DELETE", "/v1/kv/"+key) + r := k.c.newRequest("DELETE", "/v1/kv/"+strings.TrimPrefix(key, "/")) r.setWriteOptions(q) for param, val := range params { r.params.Set(param, val)