Make RESTful operations return 404 Not Found when the target resource

does not exist.

In the original implementation, GET, DELETE and PUT operations on
non-existent resources used to return 500 but not 404.
This commit is contained in:
Yuki Yugui Sonoda
2014-07-16 14:27:15 +09:00
parent 831ab28759
commit 2aa3de12d4
7 changed files with 434 additions and 71 deletions

View File

@@ -72,20 +72,8 @@ func IsEtcdConflict(err error) bool {
// Returns true iff err is an etcd error, whose errorCode matches errorCode
func isEtcdErrorNum(err error, errorCode int) bool {
if err == nil {
return false
}
switch err.(type) {
case *etcd.EtcdError:
etcdError := err.(*etcd.EtcdError)
if etcdError == nil {
return false
}
if etcdError.ErrorCode == errorCode {
return true
}
}
return false
etcdError, ok := err.(*etcd.EtcdError)
return ok && etcdError != nil && etcdError.ErrorCode == errorCode
}
func (h *EtcdHelper) listEtcdNode(key string) ([]*etcd.Node, error) {