gpt4 book ai didi

consul - 如何使用 consul 通过 HTTP API 递归获取原始值

转载 作者:行者123 更新时间:2023-12-05 00:48:46 25 4
gpt4 key购买 nike

引用以下关于 HTTP API 的 consul 文档

https://www.consul.io/api/kv.html

recurse (bool: false) - Specifies if the lookup should be recursive and key treated as a prefix instead of a literal match. This is specified as part of the URL as a query parameter.

raw (bool: false) - Specifies the response is just the raw value of the key, without any encoding or metadata. This is specified as part of the URL as a query parameter.



我期待为以下请求返回的响应中的解码值
http://localhost:8500/v1/kv/?recurse=true&raw=true
recurse选项正在工作,因为我可以看到响应 JSON 中存在的所有键/值对,但 值仍然被编码 (base64)。

raw查询参数不起作用还是我做错了什么?

最佳答案

他们的文件在某种程度上具有误导性。
这些参数将单独工作。但是,当您尝试将它们组合起来时,它们并不像您想象的那样工作。

一些替代方法来解决您的需求。

您可以先通过以下方式获取 key 列表

http://localhost:8500/v1/kv/?keys

然后,遍历键并单独获取值

http://localhost:8500/v1/kv/YourKey?raw

否则,解码代码中的值。

关于consul - 如何使用 consul 通过 HTTP API 递归获取原始值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48948965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com