如何在不使用 CDK 中的 Lambda 的情况下从 API 网关发送 JSON 正文
How to send JSON body from API Gateway without using Lambda in CDK
有没有办法在 AWS API 网关 没有 的情况下发送 JSON 正文作为对 'GET' 方法的响应使用 AWS Lambda。 这里 JSON 是常量。每次调用此 'GET' 方法时都是一样的,这就是为什么我不想为此创建 Lambda。
是的,您的用例非常适合模拟 API 集成 - https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-mock-integration.html
this.restApi.root.addResource("test").addMethod("GET", new MockIntegration({
requestTemplates: {
'application/json': `{"statusCode" : 200}`
},
integrationResponses: [
{
statusCode: '200',
responseTemplates: { 'application/json': `{"name": "John"}` }
}
]
}), {
methodResponses: [
{
statusCode: '200',
responseModels: { 'application/json': Model.EMPTY_MODEL }
}
]
});
有没有办法在 AWS API 网关 没有 的情况下发送 JSON 正文作为对 'GET' 方法的响应使用 AWS Lambda。 这里 JSON 是常量。每次调用此 'GET' 方法时都是一样的,这就是为什么我不想为此创建 Lambda。
是的,您的用例非常适合模拟 API 集成 - https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-mock-integration.html
this.restApi.root.addResource("test").addMethod("GET", new MockIntegration({
requestTemplates: {
'application/json': `{"statusCode" : 200}`
},
integrationResponses: [
{
statusCode: '200',
responseTemplates: { 'application/json': `{"name": "John"}` }
}
]
}), {
methodResponses: [
{
statusCode: '200',
responseModels: { 'application/json': Model.EMPTY_MODEL }
}
]
});