如何查询字符串或路由参数从亚马逊API网关传递到AWS LAMBDA亚马逊、网关、路由、字符串

2023-09-11 23:52:11 作者:季末,那惨淡苍白的回忆。

例如,如果我们要使用

GET /用户?名=鲍勃

GET /用户/鲍勃·

你将如何通过这两个例子作为参数传递给lambda函数?

How would you pass both of these examples as a parameter to the Lambda function?

我看到的东西有关设置的文档中的从映射,但我找不到API网关控制台设置。

I saw something about setting a "mapped from" in the documentation, but I can't find that setting in the API Gateway console.

method.request.path.parameter名名为路径参数参数名称中所定义的方法请求的页面。 method.request.querystring.parameter名名为查询字符串参数参数名称中定义该方法请求的页面。 method.request.path.parameter-name for a path parameter named parameter-name as defined in the Method Request page. method.request.querystring.parameter-name for a query string parameter named parameter-name as defined in the Method Request page.

我看不到的,即使我定义的查询字符串,这些选项要么。

I don't see either of these options even though I defined a query string.

推荐答案

要得到这个工作的步骤是:

The steps to get this working are:

转到资源 - >集成请求 点击加号或旁边的编辑图标模板下拉(奇怪的,我知道,因为模板字段已经打开,并且这里的按钮看起来呈灰色) 下明确键入应用程序/ JSON 中,即使它显示了一个默认的(如果你不这样做就不会保存,不会给你的内容类型字段错误消息)

把这个输入映射 {名:$ input.params('名')} go to Resources -> Integration Request click on the plus or edit icon next to templates dropdown (odd I know since the template field is already open and the button here looks greyed out) Explicitly type application/json in the content-type field even though it shows a default (if you don't do this it will not save and will not give you an error message)

put this in the input mapping { "name": "$input.params('name')" }

点击旁边的下拉列表中的模板(我假定这就是最终将其保存)复选框

click on the check box next to the templates dropdown (I'm assuming this is what finally saves it)

 
精彩推荐
图片推荐