gpt4 book ai didi

Azure API 管理 - 返回 JSON 响应而不发送到后端服务

转载 作者:行者123 更新时间:2023-12-03 06:56:51 24 4
gpt4 key购买 nike

我正在尝试在 Azure API 管理中创建一个 API,我只想设置一个简单的 API,该 API 返回状态为 200 的 JSON 响应,而不将其发送到任何后端服务。我找到了一种通过模拟来做到这一点的方法,但想知道是否有更好的方法。

谢谢

最佳答案

我通过在入站处理中添加策略来解决这个问题:

<policies>
<inbound>
<base />
<return-response>
<set-status code="200" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>{
"test_key": "hello"
}</set-body>
</return-response>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>

关于Azure API 管理 - 返回 JSON 响应而不发送到后端服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72876939/

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