【发布时间】:2016-07-07 10:38:03
【问题描述】:
我正在配置 lambda 函数的 API 网关与 Serverless Framework 版本 0.4.2 的集成。
我的问题是定义端点的请求参数。 AWS docs for API gateway 条目说:
请求参数
表示 Amazon API Gateway 可以接受的请求参数。请求参数表示为键/值映射,源作为键,布尔标志作为值。布尔标志用于指定参数是否是必需的。源必须匹配模式 method.request.{location}.{name},其中 location 是查询字符串、路径或标头。 name 是一个有效的、唯一的参数名称。此处指定的源可用于集成以映射到集成请求参数或模板。
据我了解,s-function.json 中的配置直接提供给 AWS CLI,因此我指定了以下格式的请求参数:
"method.request.querystring.startYear": true。但是,我收到了 Invalid mapping expression specified: true 错误。我也尝试将配置指定为"method.request.querystring.startYear": "true",结果相同。
s-function.json:
{
"name": "myname",
// etc...
"endpoints": [
{
"path": "mypath",
"method": "GET",
"type": "AWS",
"authorizationType": "none",
"apiKeyRequired": false,
"requestParameters": {
"method.request.querystring.startYear": true,
"method.request.querystring.startMonth": true,
"method.request.querystring.startDay": true,
"method.request.querystring.currentYear": true,
"method.request.querystring.currentMonth": true,
"method.request.querystring.currentDay": true,
"method.request.querystring.totalDays": true,
"method.request.querystring.volume": true,
"method.request.querystring.userId": true
},
// etc...
}
],
"events": []
}
有什么想法吗?提前致谢!
【问题讨论】:
标签: amazon-web-services aws-cli aws-api-gateway serverless-framework