我正在尝试在gateway创建一个端点,它将调用多个服务调用,并将它们组合到一个响应中。使用express-gateway可以吗?
这是我的gateway.config.yml。
http:
port: 8080
admin:
port: 9876
host: localhost
apiEndpoints:
api:
host: localhost
paths: '/ip'
uuid:
host: localhost
paths: '/uuid'
agent:
host: localhost
paths: '/user-agent'
serviceEndpoints:
httpbin:
url: 'https://httpbin.org'
uuid:
url: 'https://httpbin.org'
agent:
url: 'https://httpbin.org'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
default:
apiEndpoints:
- api
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
- key-auth:
- proxy:
- action:
serviceEndpoint: httpbin
changeOrigin: true
default-1:
apiEndpoints:
- uuid
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
- key-auth:
- proxy:
- action:
serviceEndpoint: uuid
changeOrigin: true
default-2:
apiEndpoints:
- agent
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
- key-auth:
- proxy:
- action:
serviceEndpoint: agent
changeOrigin: true基本上,我希望将所有声明的serviceEndpoints合并到一条路径中。假设我触发了/ip,它将调用'api,uuid,agent‘serviceEndpoints并将它们组合到一个响应中。这有可能吗?
发布于 2020-01-14 18:04:42
遗憾的是,Express Gateway并不真正支持这样的场景。你将不得不编写你自己的插件--但这不会那么容易。
发布于 2020-10-11 17:53:57
在这方面有多种建议的方法,你可以根据你的用例,技术堆栈,团队和技术技能和其他变量来权衡。
https://stackoverflow.com/questions/59729362
复制相似问题