首页 > 解决方案 > 将参数传递给 WSO2 AM 后台 api

问题描述

我正在实施 WSO2 AM,但我有一些疑问。我想为我目前拥有的所有服务实现一个 api 网关。

(如果您认为有更容易实现的开源网关 api 也会有所帮助)

端点位于带有 express 的 NodeJS 中。它们具有以下格式:

http://localhost:3000/x/x1/:param1/:param2

http://localhost:3000/x/x2/:param1/:param2/:param3

我的想法是创建一个具有以下格式的端点的 wn wso2 AP api:

https://localhost:3000/x/

wso2 中生成的 api 将是:

http://localhost:3000/x

然后作为资源获取添加x1和其他参数,问题是我不知道如何添加x1和参数以便终点是

http://localhost:3000/x/x1/:param1/:param2

标签: wso2wso2-amapi-gateway

解决方案


在 API Manager 中,以下是 API 的公开方式。

您拥有具有以下上下文和资源模式的后端服务。

http://localhost:3000/ {context}/{resource}/{params...}

http://localhost:3000/x/x1/ ...

http://localhost:3000/x/x2/ ...

应添加与后端服务同名的资源。

{动词} x1/{param1}/{param2}

路径参数应以上述格式提供。

此 API 的后端端点应提供如下。

http://localhost:3000/x/

调用 api 时,网关会将资源和参数附加到后端端点。

https://localhost:8243/xapi/1.0.0/x1/param1/param2 ==> http://localhost:3000/x/x1/param1/param2


推荐阅读