Trim leading slash on key to avoid redirect (golang/go#4800) (#2476)

This commit is contained in:
Kyle Havlovitz 2016-11-05 00:55:10 -04:00 committed by James Phillips
parent 9adc3854d1
commit 07eeef6f1f
1 changed files with 2 additions and 2 deletions

View File

@ -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) { 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) r.setQueryOptions(q)
for param, val := range params { for param, val := range params {
r.params.Set(param, val) 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) { 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) r.setWriteOptions(q)
for param, val := range params { for param, val := range params {
r.params.Set(param, val) r.params.Set(param, val)