我在 Azure APIM 上有一个服务有一个参数令牌。
客户端应提供代币值。 我想在响应中显示令牌值,它会怎样?
<policies>
<inbound>
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<set-variable name="token" value="@(token)" />
</outbound>
<on-error>
<base />
</on-error>
我已使用以下策略来写入响应中的令牌值。
<outbound>
<base />
<set-variable name="token" value="@(context.Request.Headers.GetValueOrDefault("token"))" />
<set-body>@("Token: "+ ((string)context.Variables["token"]))</set-body>
</outbound>
请确保在 Header 中传递 token 值。
这样就可以在响应中传递token值了。