Consistently handle (lack of) trailing slash in HTTP request

If I GET the /v2/keys collection without a trailing slash, I get the following response:

```
% curl -i localhost:4002/v2/keys
HTTP/1.1 200 OK
Content-Type: application/json
X-Etcd-Index: 10
X-Raft-Index: 1477
X-Raft-Term: 1
Date: Fri, 24 Oct 2014 20:41:04 GMT
Transfer-Encoding: chunked

{"action":"get","node":{"dir":true,"nodes":[{"key":"/foo","value":"bar","modifiedIndex":10,"createdIndex":10}],"modifiedIndex":10,"createdIndex":10}}
```

However, if I GET the /v2/admin/members collection without a trailing slash, I get a 301:

```
% curl -i localhost:4002/v2/admin/members
HTTP/1.1 301 Moved Permanently
Location: /v2/admin/members/
Date: Fri, 24 Oct 2014 20:41:08 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked

<a href="/v2/admin/members/">Moved Permanently</a>.
```

Se need to be consistent here. The "correct" thing to do here is to require no trailing slash to access the collection, while the presence of a trailing slash (regardless of what follows it) meaning the request references a specific item in the collection. The solution most helpful to our users is to handle a trailing slash followed by an empty path element the same as if the trailing slash was not provided. 
I don't understand - it reads clearly to me. Can you suggest something?
On Oct 24, 2014 5:21 PM, "Yicheng Qin" <notifications@github.com> wrote:

> In etcdserver/etcdhttp/http.go:
>
> > @@ -153,6 +154,14 @@ func (h serverHandler) serveMachines(w http.ResponseWriter, r *http.Request) {
> >  	w.Write([]byte(strings.Join(endpoints, ", ")))
> >  }
> >
> > +// trimPrefix removes a given prefix and any slash following the prefix
> > +// e.g.: trimPrefix("foo", "foo") == trimPrefix("foo/", "foo") == ""
> > +func trimPrefix(p, prefix string) (s string) {
> > +	s = strings.TrimPrefix(p, prefix)
> > +	s = strings.TrimPrefix(s, "/")
>
> it needs to update the comment i think
> a given prefix and any slash following the prefix
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/coreos/etcd/pull/1392/files#r19371442>.
>