我们可以在 WSO2 Managed API 端点 URL 中映射版本值吗?
Can we map the version value in the WSO2 Managed API endpoint URL?
我正在创建一个带有一些上下文路径和 v1 版本的 API:
然后我尝试提供指向后端的沙箱和生产端点。目标是具有以下内容:
PRO: http://localhost:9090/myapi/{version}
SB: http://localhost:8080/myapi/{version}
也就是说我想在后端路径中使用版本字段。
但是我收到以下错误:
Invalid Sandbox Endpoint URI. Please refer HTTP Endpoint documentation
of the WSO2 ESB for details.
Invalid Production Endpoint URI. Please
refer HTTP Endpoint documentation of the WSO2 ESB for details.
有什么办法吗?
更新:
我找到了以下文章 (https://docs.wso2.com/display/AM260/Map+the+Parameters+of+your+Backend+URLs+with+the+API+Publisher+URLs),其中解释了如何使用 uri.var 前缀映射值。所以现在在我的端点中我有:
PRO: http://localhost:9090/myapi/{uri.var.version}
SB: http://localhost:8080/myapi/{uri.var.version}
现在的问题是它的值为空。
您可能必须创建 In Flow 调解策略才能获得端点 URL 的 API 版本。
例如,您可以创建一个名为 "VersionSequence.xml" 的文件并将以下内容添加到该文件中。该序列中介将允许将 REST API 版本存储到名为 "uri.var.version" 的 属性 中。
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="VersionSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property expression="$ctx:SYNAPSE_REST_API_VERSION" name="uri.var.version"/>
<log level="custom">
<property expression="get-property('uri.var.version')" name="APIVersion"/>
</log>
</sequence>
然后您可以将此中介策略上传到“启用消息中介”部分的 In-Flow 在 API 管理器中实施 API。之后,您可以如下设置端点,它将从您在中介流中创建的 "uri.var.version" 属性 获取版本。
我正在创建一个带有一些上下文路径和 v1 版本的 API:
然后我尝试提供指向后端的沙箱和生产端点。目标是具有以下内容:
PRO: http://localhost:9090/myapi/{version}
SB: http://localhost:8080/myapi/{version}
也就是说我想在后端路径中使用版本字段。
但是我收到以下错误:
Invalid Sandbox Endpoint URI. Please refer HTTP Endpoint documentation of the WSO2 ESB for details.
Invalid Production Endpoint URI. Please refer HTTP Endpoint documentation of the WSO2 ESB for details.
有什么办法吗?
更新:
我找到了以下文章 (https://docs.wso2.com/display/AM260/Map+the+Parameters+of+your+Backend+URLs+with+the+API+Publisher+URLs),其中解释了如何使用 uri.var 前缀映射值。所以现在在我的端点中我有:
PRO: http://localhost:9090/myapi/{uri.var.version}
SB: http://localhost:8080/myapi/{uri.var.version}
现在的问题是它的值为空。
您可能必须创建 In Flow 调解策略才能获得端点 URL 的 API 版本。
例如,您可以创建一个名为 "VersionSequence.xml" 的文件并将以下内容添加到该文件中。该序列中介将允许将 REST API 版本存储到名为 "uri.var.version" 的 属性 中。
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="VersionSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property expression="$ctx:SYNAPSE_REST_API_VERSION" name="uri.var.version"/>
<log level="custom">
<property expression="get-property('uri.var.version')" name="APIVersion"/>
</log>
</sequence>
然后您可以将此中介策略上传到“启用消息中介”部分的 In-Flow 在 API 管理器中实施 API。之后,您可以如下设置端点,它将从您在中介流中创建的 "uri.var.version" 属性 获取版本。