Yiyiyimu commented on a change in pull request #2036:
URL: https://github.com/apache/apisix/pull/2036#discussion_r488745722



##########
File path: apisix/core/etcd.lua
##########
@@ -44,24 +48,134 @@ end
 _M.new = new
 
 
+local function kvs_to_node(kvs)
+    local node = {}
+    node.key = kvs.key
+    node.value = kvs.value
+    node.createdIndex = tonumber(kvs.create_revision)
+    node.modifiedIndex = tonumber(kvs.mod_revision)
+    return node
+end
+
+local function kvs_to_nodes(res)
+    res.body.node.dir = true
+    res.body.node.nodes = {}
+    for i=2, #res.body.kvs do
+        res.body.node.nodes[i-1] = kvs_to_node(res.body.kvs[i])
+    end
+    return res
+end
+
+
+local function not_found(res)
+    res.body.message = "Key not found"
+    res.reason = "Not found"
+    res.status = 404
+    return res
+end
+
+
+function _M.get_format(res, realkey)
+    if res.body.error == "etcdserver: user name is empty" then

Review comment:
       Some does and some don't. For example in this case, ngx.status is set to 
400.
   ```
   {
     body = {
       code = 3,
       error = "etcdserver: user name is empty",
       message = "etcdserver: user name is empty"
     },
     body_reader = <function 1>,
     has_body = true,
     headers = {...},
     read_body = <function 4>,
     read_trailers = <function 5>,
     reason = "Bad Request",
     status = 400,
     trailer_reader = <function 6>
   }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to