简体   繁体   English

WSO2 API Manager自定义路由

[英]WSO2 API Manager Custom Routing

Is there a way to dynamically set the endpoints in WSO2 API Manager to something other than the configured production and sandbox URLs? 除了在配置的生产和沙箱URL之外,是否可以将WSO2 API Manager中的端点动态设置为其他方式? In my case, I want to route based on an incoming header value; 就我而言,我想根据传入的标头值进行路由; resulting in something like: 结果是:

https://my_dynamically_determined_subdomain.my_static_domain.com

I tried doing this with a custom handler class that writes my desired URL to the "To" header, but that doesn't seem to affect the routing. 我尝试使用一个自定义处理程序类来执行此操作,该类将所需的URL写入“ To”标头中,但这似乎并不影响路由。

Is there another way to accomplish this? 还有另一种方法可以做到这一点吗?

Your approach seems to be good. 您的方法似乎很好。 You can set "To" header dynamically. 您可以动态设置“ To”标题。 But you have to use a Default Endpoint , instead of a HTTP Endpoint . 但是您必须使用默认端点 ,而不是HTTP端点 Default Endpoint will send the message to the URL found in "To" header. 默认端点会将消息发送到“收件人”标头中找到的URL。 Please modify your inSequence of the API Configuration (found in $AM_HOME/repository/deployment/server/synapse-configs/default/api/your-api.xml) to replace the HTTP endpoint with a Default endpoint, as shown below. 请修改您的API配置顺序(位于$ AM_HOME / repository / deployment / server / synapse-configs / default / api / your-api.xml中),以将HTTP端点替换为默认端点,如下所示。

API经理默认端点

If you want to do this to all of your APIs, then you can edit velocity_templates.xml so that all the APIs will be published with default endpoints automatically. 如果要对所有API都执行此操作,则可以编辑Velocity_templates.xml,以便所有API都将使用默认端点自动发布。 Please refer this doc for more details on this. 请参考此文档以获取更多详细信息。 It is worth to have a look at this blog post which is discussing a similar pattern what you are trying to do. 值得看一下这篇博客 ,该博客正在讨论您尝试做的类似模式。

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

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