繁体   English   中英

自定义处理程序中的 WSO2 API 属性

[英]WSO2 API properties in custom handler

如何在 WSO2 自定义处理程序中访问 API 相关信息,例如 API 属性(在发布者中定义)?

您可以使用消息上下文对象来访问API信息:

messageContext.getProperty("api.ut.HTTP_METHOD")

请参阅样本以获取更多信息。

请参考以下代码。 它将打印所有messagecontext属性键集及其值。

        Set propertySet = context.getPropertyKeySet();
    for (Object propertyKey : propertySet) {

        log.info("Key: " + propertyKey.toString() + "| value: "
                + context.getProperty(propertyKey.toString()));
    }

另请参阅

正如我所见,处理程序/调解器可以通过本地注册表访问 api 属性

在 xml 配置中定义时可以是这样

<sequence name="custom-sequence" xmlns="http://ws.apache.org/ns/synapse">
  <log level="custom">
      <property 
        name="prop"
        expression="get-property('registry', 
          fn:concat(
            'gov:/apimgt/applicationdata/provider/',
            $ctx:api.ut.apiPublisher, '/',
            $ctx:api.ut.api, '/',
            $ctx:api.ut.version, '/',
            'api@api_meta.my_property'
          ))" />
  </log>
</sequence>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM