自定义策略 API 管理器



我试图创建一个自定义策略,目的是服务掩码:

API 中的原始服务:

http://API/v1/profile
http://API/v1/account

带面具:

http://API/v1/user-profile
http://API/v1/user-account

并结合用户蜜蜂的答案,这是这个问题的解决方案:

<switch source="get-property('axis2', 'REST_URL_POSTFIX')">
<case regex="/v1/kyc-profile">
<property name="REST_URL_POSTFIX" value="/v1/profile" scope="axis2"/>
</case>
<case regex="/v1/kyc-account">
<property name="REST_URL_POSTFIX" value="/v1/account" scope="axis2"/>
</case>
</switch>

但是此解决方案仅适用于服务是静态的,但我还有其他服务,类似于:

http://API/v1/user-profile/{id-user}/details
http://API/v1/user-profile/{id-user}?expand=some_information

对于最后一个服务,我有这个:

<switch source="get-property('axis2', 'REST_URL_POSTFIX')">
<case regex="v1/user-profile/[/wW]*">
<property name="REST_URL_POSTFIX" value="/v2/cliente/{id-user}?expand=some_information" scope="axis2"/>
</case>
</switch>

[/\w\W]*这部分是{id-user}?expand=some_information和类似内容的正则表达式。

问题是:我需要放置动态值,因为属性(<property name="REST_URL_POSTFIX"value="THIS">scope="axis2"/>(采用此文本,例如:

服务前到政策

http://API/v1/user-profile/1?expand=some_information

服务后到政策

http://API/v1/user-profile/{id-user}?expand=some_information

我的问题是:

  1. 如何为服务放置类似于以下内容的动态值:http://API/v1/user-profile/{id-user}?expand=some_information
  2. 对于其他服务,http://API/v1/user-profile/{id-user}/details我有类似的情况,如何解决?

在中介序列中,尝试按如下方式更改后端网址。

http://API/v1/user-profile/{uri.var.id-user}?expand=some_information

例:

<switch source="get-property('axis2', 'REST_URL_POSTFIX')">
<case regex="v1/user-profile/[/wW]*">
<property name="REST_URL_POSTFIX" value="/v2/cliente/{uri.var.id-user}?expand=some_information" scope="axis2"/>
</case>
</switch>

最新更新