以编程方式在 WSO2 API Manager 中添加自定义处理程序 [英] Programmatically add custom handler in WSO2 API Manager

查看:10
本文介绍了以编程方式在 WSO2 API Manager 中添加自定义处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过使用 WSO2 API Manager 的 Publisher存储 HTTP APIs.我有自定义处理程序,然后通过编辑 <APIM_HOME>/repository/deployment/server/synapse-configs/default/api 中的 XML 文件将其映射到我的 API.

I create and subscribe new APIs through an automated process that uses WSO2 API Manager's Publisher and Store HTTP APIs respectively. I have custom handlers that I then map to my APIs by editing the XML files in <APIM_HOME>/repository/deployment/server/synapse-configs/default/api.

有没有办法以编程方式将处理程序映射到新创建的 API,这样我就不必手动编辑 XML?换句话说,一个 API 或其他方法来查看 API 的当前处理程序,并添加/删除?

Is there a way to programmatically map the handlers to the newly created APIs so that I don't have to edit the XML manually? In other words, an API or other method to see the current handlers for an API, and add/remove?

推荐答案

就我而言,我有许多处理程序和许多 API.并非所有处理程序都适用于所有 API,也没有处理程序适用于所有 API.

In my case, I have many handlers and many APIs. Not all handlers apply to all APIs and no handler is applicable to all APIs.

我通过在部署到 API Manager 的 Carbon 实例的 WAR 文件中创建独立的 HTTP API 解决了这个问题.之后调用 WSO2 Publisher API 的同一服务调用我的 HTTP API.API 将处理程序类名称作为参数,并将适当的元素注入本地文件系统上的 API 定义 XML 文件(我使用 JDOM).API Manager 会自动检测并重新加载修改后的 XML,一切顺利.

I solved this by creating a standalone HTTP API in a WAR file that I deployed to API Manager's Carbon instance. The same service that calls the WSO2 Publisher API calls my HTTP API afterward. The API takes in handler class names as parameters, and injects the appropriate elements into the API definition XML files on the local filesystem (I used JDOM). API Manager automatically detects and reloads the modified XML and it's good to go.

这篇关于以编程方式在 WSO2 API Manager 中添加自定义处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆