我需要实施一项策略,根据 URL(机构代码)中的内容将请求转发到正确的后端
例如,
我不知道
谢谢!
您可以使用下面给出的策略来提取
AGENCYCODE
并重写 Url。
<policies>
<inbound>
<base />
<set-variable name="agencyCode" value="@(System.Text.RegularExpressions.Regex.Match(context.Request.OriginalUrl.Path, @"(?<=/int/my/v1/)(.*)(?=/system/ping)").Value)" />
<rewrite-uri template="/int/my/v1/system/ping" />
<choose>
<when condition="@((string)context.Variables["agencyCode"] == "AABB1")">
<set-backend-service base-url="http://10.10.10.1:8080" />
</when>
<when condition="@((string)context.Variables["agencyCode"] == "AABB2")">
<set-backend-service base-url="http://10.10.10.2:8080" />
</when>
</choose>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
追踪-