[英]How to combined multiple responses with single gateway endpoint using express gateway
I'm trying to create an endpoint at gateway that will call multiple service calls and combine them in one response.我正在尝试在网关创建一个端点,它将调用多个服务调用并将它们组合在一个响应中。 Is that possible with express-gateway?使用 express-gateway 可以吗?
This is my gateway.config.yml.这是我的 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
Basically, I want to combine all of declared serviceEndpoints to one path.基本上,我想将所有声明的 serviceEndpoints 组合到一个路径中。 Let say I trigger /ip , it will call 'api,uuid,agent' serviceEndpoints and combine them all to one response.假设我触发 /ip ,它将调用 'api,uuid,agent' serviceEndpoints 并将它们全部组合为一个响应。 Is that possible?那可能吗?
Express Gateway does not really support such scenario unfortunately.不幸的是,Express Gateway 并不真正支持这种情况。 You're going to have to write your own plugin — but it is not going to be so easy.您将不得不编写自己的插件——但这不会那么容易。
There are multiple approaches suggested on this regard, which you can weigh based on your use-case, tech-stack, team & tech-skills and other variables.在这方面建议了多种方法,您可以根据您的用例、技术堆栈、团队和技术技能以及其他变量进行权衡。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.