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



我试图在Azure 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>

最新更新