Skip to content

Commit

Permalink
Trim leading slash on key to avoid redirect (golang/go#4800)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyhavlov committed Nov 4, 2016
1 parent e6e35d9 commit 67431cc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 67431cc

Please sign in to comment.