如何修改WSO2 APIM处理程序的顺序

我正在将WSO2 APIM 1.10.0与此处引用的自定义处理程序一起使用

我有2个全局自定义处理程序:

  1. HeaderSwapHandler
  2. APIInforHandler

而且我希望这两个自定义处理程序在创建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>

HeaderSwapHandlerAPIInforHandler处理程序的顶部和底部。

有什么办法吗?

编辑并解决

我的原始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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在PHP中检索SAML2令牌以从WSO2 APIM获取OAuth令牌

WSO2 APIM:类介体和自定义处理程序之间的区别

如何在wso2 EI 6.1.1中为特定API配置自定义突触处理程序

WSO2 APIM中如何针对外部/第三方API处理外部身份验证

无法修改共享的应用程序WSO2 APIM 2.6.0

如何仅将WSO2自定义处理程序应用于某些API?

我们如何在WSO2自定义处理程序中确定请求环境(沙箱/生产)?

WSO2配置(IS API保护APIM端点)

在WSO2中处理令牌过期

WSO2 APIM 2.6.0-群集和分布式-如何发布API

无法升级到WSO2 APIM 2.1.0到WSO2 APIM 2.6.0

WSO2 APIM与WSO2 EI 6.6、7.0和DSS

如何在WSO2 3.2.0 APIM中启用隐式授予?

WSO2 ESB如何独立处理肥皂操作

在WSO2 APIM中读取动态查询参数

WSO2 APIM v1.9.0与外部LDAP集成

将应用程序信息从WSO2 APIM传递到特定的API

如何正确设定WSO2 API的顺序?电子邮件发送中断

WSO2 APIM群集-如何缩短响应时间?

WSO2 APIM 无法从商店创建访问令牌

WSO2 APIM 应用程序注册 urn:approve action not found

WSO2 EI:如何在使用 vfs 选择 csv 文件时处理 WSO2 中的瑞典字符

wso2 在 Eclipse 中调试处理程序

授权代码授权在 WSO2 APIM 中生成 405

如何在 WSO2 EI/ESB 中实现顺序后端调用?

如何在 WSO2 APIM 3.0 中运行多配置文件

WSO2 APIM 角色验证

如何为 wso2 apim 中的每天条目添加自定义日志文件?

在 WSO2 APIM 3.2.0 中修改/删除 wso2 类中介或 xml 序列中的请求有效负载内容