在无数据库模式下,我使用的是kong API网关。
因此,我有一个kong.yaml文件,如下所示:
_format_version: "2.1"
_transform: true
services:
- name: service1
url: http://service1:port/sample-path
routes:
- name: service1
methods:
- GET
paths:
- /service1/sample-path
strip_path: true如您所见,api-网关将api-gatway的/service1/sample-path端点的请求发送给http://service1:port/sample-path。
我正在寻找一种添加新服务的方法,这样当请求被发送到api的/oas端点时,它会加载一个yaml或json文件,并将其作为响应返回。
实际上,我正在寻找一种返回静态响应的方法,而不是发送请求?
知道怎么做吗?
伪码
_format_version: "2.1"
_transform: true
services:
- name: service1
url: http://service1:port/sample-path
routes:
- name: service1
methods:
- GET
paths:
- /service1/sample-path
strip_path: true
- name: oas
url: STATIC YAML OR JSON FILE
routes:
- name: oas
methods:
- GET
paths:
- /oas
strip_path: true发布于 2022-06-09 20:50:18
您可以使用插件https://github.com/IntelliGrape/kong-plugin-static-response来处理这个问题。
https://stackoverflow.com/questions/72562657
复制相似问题