Open fussybeaver opened 5 years ago
Here are the few different kind of responses for this endpoint.
Assuming the commands have been issues before:
# Put null value
consul kv put test/other/path/value2
# Put non-null value
consul kv put test/other/path/value2 some-value
HTTP: 404 return: nil
curl -i localhost:8500/v1/kv/non-existing-prefix?keys
HTTP/1.1 404 Not Found
Vary: Accept-Encoding
X-Consul-Index: 21
X-Consul-Knownleader: true
X-Consul-Lastcontact: 0
Date: Mon, 16 Mar 2020 18:45:37 GMT
Content-Length: 0
HTTP: 200 return Array[String]
curl -i localhost:8500/v1/kv/test?keys
HTTP/1.1 200 OK
Content-Type: application/json
Vary: Accept-Encoding
X-Consul-Index: 21
X-Consul-Knownleader: true
X-Consul-Lastcontact: 0
Date: Mon, 16 Mar 2020 18:44:10 GMT
Content-Length: 52
[
"test/other/path/value2",
"test/value1"
]
HTTP 404 return nil
curl -i localhost:8500/v1/kv/non-existing-prefix
HTTP/1.1 404 Not Found
Vary: Accept-Encoding
X-Consul-Index: 21
X-Consul-Knownleader: true
X-Consul-Lastcontact: 0
Date: Mon, 16 Mar 2020 18:46:26 GMT
Content-Length: 0
HTTP 200 return Array[KeyObject] BEWARE: KeyObject.Value might be null
curl -i localhost:8500/v1/kv/test/value1
HTTP/1.1 200 OK
Content-Type: application/json
Vary: Accept-Encoding
X-Consul-Index: 11
X-Consul-Knownleader: true
X-Consul-Lastcontact: 0
Date: Mon, 16 Mar 2020 18:47:33 GMT
Content-Length: 166
[
{
"LockIndex": 0,
"Key": "test/value1",
"Flags": 0,
"Value": null,
"CreateIndex": 11,
"ModifyIndex": 11
}
]
HTTP: 404
curl -i localhost:8500/v1/kv/non-existing-prefix
HTTP/1.1 404 Not Found
Vary: Accept-Encoding
X-Consul-Index: 21
X-Consul-Knownleader: true
X-Consul-Lastcontact: 0
Date: Mon, 16 Mar 2020 18:41:51 GMT
Content-Length: 0
Same output as simple, but multiple values might bee returned:
curl -i localhost:8500/v1/kv/test?recurse
HTTP/1.1 200 OK
Content-Type: application/json
Vary: Accept-Encoding
X-Consul-Index: 21
X-Consul-Knownleader: true
X-Consul-Lastcontact: 0
Date: Mon, 16 Mar 2020 18:49:44 GMT
Content-Length: 354
[
{
"LockIndex": 0,
"Key": "test/other/path/value2",
"Flags": 0,
"Value": "c29tZS12YWx1ZQ==",
"CreateIndex": 16,
"ModifyIndex": 21
},
{
"LockIndex": 0,
"Key": "test/value1",
"Flags": 0,
"Value": null,
"CreateIndex": 11,
"ModifyIndex": 11
}
]
KeyObject := {
LockIndex uint64
Key string
Flags uint64
Value Option<[]byte> (serialized as base64, can be null)
CreateIndex: uint64
ModifyIndex: uint64
}
Operation | HTTP Code | type returned | X-Consul-Index |
---|---|---|---|
path, existing | 200 | Array[KeyObject] | Last-Modified index of path |
path, not found | 404 | Array[KeyObject] | Last index of change in KV |
?keys, existing prefix | 200 | Array[String] | Last Index of change in prefix |
?keys, not found | 404 | nil, no Content | Last index of change in KV |
?recurse, existing prefix | 200 | Array[String] | Last Index of change in prefix |
?recurse, not found | 200 | nil, no Content | Last Index of change in prefix |
I believe I'm using the
consul:1.4.4
docker image, and listing a path returns anull
value. This is the response when I use curl:This causes the consul-rust library to fail on JSON deserialization.