我正在将WSO2 APIM 1.10.0与此处引用的自定义处理程序一起使用。
我有2个全局自定义处理程序:
而且我希望这两个自定义处理程序在创建API时的顺序如下。
<handlers>
<handler class="com.wso2.header.handler.HeaderSwapHandler"/>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
<property name="apiImplementationType" value="ENDPOINT"/>
</handler>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler">
<property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/>
<property name="policyKeyApplication"
value="gov:/apimgt/applicationdata/app-tiers.xml"/>
<property name="id" value="A"/>
<property name="policyKeyResource"
value="gov:/apimgt/applicationdata/res-tiers.xml"/>
</handler>
<handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageHandler"/>
<handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtGoogleAnalyticsTrackingHandler">
<property name="configKey" value="gov:/apimgt/statistics/ga-config.xml"/>
</handler>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/>
<handler class="com.wso2.header.handler.APIInforHandler"/>
</handlers>
HeaderSwapHandler
在APIInforHandler
处理程序的顶部和底部。
有什么办法吗?
编辑并解决
我的原始velocity_template.xml
像是:
<handlers xmlns="http://ws.apache.org/ns/synapse">
<handler class="com.wso2.header.handler.HeaderSwapHandler"/>
<handler class="com.wso2.header.handler.APIInforHandler"/>
#foreach($handler in $handlers)
<handler xmlns="http://ws.apache.org/ns/synapse" class="$handler.className">
#if($handler.hasProperties())
#set ($map = $handler.getProperties() )
#foreach($property in $map.entrySet())
<property name="$!property.key" value="$!property.value"/>
#end
#end
</handler>
#end
</handlers>
#end
#end
#if($apiStatus == 'PROTOTYPED')
#end
## end of apiIsBlocked check
<handlers>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
<property name="inline" value="INLINE"/>
</handler>
</handlers>
</api>
只需更改为:
<handlers xmlns="http://ws.apache.org/ns/synapse">
<handler class="com.wso2.header.handler.HeaderSwapHandler"/>
#foreach($handler in $handlers)
<handler xmlns="http://ws.apache.org/ns/synapse" class="$handler.className">
#if($handler.hasProperties())
#set ($map = $handler.getProperties() )
#foreach($property in $map.entrySet())
<property name="$!property.key" value="$!property.value"/>
#end
#end
</handler>
#end
<handler class="com.wso2.header.handler.APIInforHandler"/>
</handlers>
#end
#end
#if($apiStatus == 'PROTOTYPED')
#end
## end of apiIsBlocked check
<handlers>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
<property name="inline" value="INLINE"/>
</handler>
</handlers>
</api>
那可以解决我的问题。
在您引用的同一页面中,它具有Engaging the custom handler
部分。它显示了如何使用velocity_template.xml
新的处理程序来使用API。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句