如何使用快速网关将多个响应与单个网关端点组合在一起

问题描述 投票:0回答:1

我正在尝试在网关处创建一个端点,该端点将调用多个服务调用并将它们组合为一个响应。 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并将它们全部组合成一个响应。有可能吗?

node.js express api-gateway express-gateway
1个回答
0
投票

不幸的是,Express Gateway并不真正支持这种情况。您将不得不编写自己的插件-但这不会那么容易。

© www.soinside.com 2019 - 2024. All rights reserved.