coreos/etcd — pull request #1392 by jonboulle (2014-10-24 23:59:38+00:00)
Title: 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

Moved Permanently.
```

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.