agent: Key list of root returns empty list with 200 instead of 404

This commit is contained in:
Armon Dadgar 2014-04-30 14:21:02 -07:00 committed by Jack Pearkes
parent ee1eefc997
commit cd08e81958
1 changed files with 8 additions and 2 deletions

View File

@ -95,11 +95,17 @@ func (s *HTTPServer) KVSGetKeys(resp http.ResponseWriter, req *http.Request, arg
}
setMeta(resp, &out.QueryMeta)
// Check if we get a not found
if len(out.Keys) == 0 {
// Check if we get a not found. We do not generate
// not found for the root, but just provide the empty list
if len(out.Keys) == 0 && listArgs.Prefix != "" {
resp.WriteHeader(404)
return nil, nil
}
// Use empty list instead of null
if out.Keys == nil {
out.Keys = []string{}
}
return out.Keys, nil
}