我有几个正在运行的快速端点正在查询数据库。我正在尝试像这样解析我的 express-gateway 中的参数:
paths: ['/users', '/users/:userId']
用户端点在 localhost 上运行,/users
并按预期返回所有用户。问题是它/users/:userId
也会返回所有用户 - 它应该只返回一个。
当我尝试在没有网关的情况下调用端点时,它工作正常(http://localhost:3000/users/F692D717-F304-4D9B-A302-44F143923A93/)
但它不能通过网关工作。似乎它永远不会到达最后一个端点或不解析参数。
我的gateway.config.yml
:
http:
port: 8080
admin:
port: 9876
hostname: localhost
apiEndpoints:
users:
host: "*"
paths: ['/users', '/users/:userId']
accounts:
host: "*"
paths: '/accounts'
companies:
host: "*"
paths: '/companies'
serviceEndpoints:
users:
url: 'http://localhost:3000/users'
accounts:
url: 'http://localhost:3002/accounts'
companies:
url: 'http://localhost:3001/companies'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
users:
apiEndpoints:
- users
policies:
- proxy:
- action:
serviceEndpoint: users
changeOrigin: false
ignorePath: true
accounts:
apiEndpoints:
- accounts
policies:
- proxy:
- action:
serviceEndpoint: accounts
changeOrigin: false
ignorePath: true
companies:
apiEndpoints:
- companies
policies:
- proxy:
- action:
serviceEndpoint: companies
changeOrigin: false
ignorePath: true