一、非代理lambda(自定義lambda) 需要自己構建映射
eg:
{
"city": "$input.params('city')",
"time": "$input.params('time')",
"day": "$input.params('day')",
"name": "$inputRoot.callerName"
}
https://oq7all40u3.execute-api.cn-north-1.amazonaws.com.cn/test/test?time=123456
event 會收到您傳遞的數據
{
"time": "123456"
}
二、代理集成lambda
在 Lambda 代理集成中,當客戶端提交 API 請求時,API Gateway 會按原樣將原始請求傳遞給集成的 Lambda 函數,但不會保留請求參數的順序。
eg: https://oq7all40u3.execute-api.cn-north-1.amazonaws.com.cn/test/test?time=123456
Lambda event收到的數據
{
"resource": "/test",
"path": "/test",
"httpMethod": "GET",
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5,zh-TW;q=0.4",
"Host": "oq7all40u3.execute-api.cn-north-1.amazonaws.com.cn",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "none",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36",
"X-Amzn-Trace-Id": "Root=1-5d8d8250-1f8874904764cbb8b777e598",
"X-Forwarded-For": "119.254.228.2",
"X-Forwarded-Port": "443",
"X-Forwarded-Proto": "https"
},
"multiValueHeaders": {
"accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"],
"accept-encoding": ["gzip, deflate, br"],
"accept-language": ["zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5,zh-TW;q=0.4"],
"Host": ["oq7all40u3.execute-api.cn-north-1.amazonaws.com.cn"],
"sec-fetch-mode": ["navigate"],
"sec-fetch-site": ["none"],
"sec-fetch-user": ["?1"],
"upgrade-insecure-requests": ["1"],
"User-Agent": ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"],
"X-Amzn-Trace-Id": ["Root=1-5d8d8250-1f8874904764cbb8b777e598"],
"X-Forwarded-For": ["119.254.228.2"],
"X-Forwarded-Port": ["443"],
"X-Forwarded-Proto": ["https"]
},
"queryStringParameters": {
"time": "123456"
},
"multiValueQueryStringParameters": {
"time": ["123456"]
},
"pathParameters": null,
"stageVariables": null,
"requestContext": {
"resourceId": "e837yf",
"resourcePath": "/test",
"httpMethod": "GET",
"extendedRequestId": "AqFMnH2NBTIFXSQ=",
"requestTime": "27/Sep/2019:03:30:24 +0000",
"path": "/test/test",
"accountId": "936669166135",
"protocol": "HTTP/1.1",
"stage": "test",
"domainPrefix": "oq7all40u3",
"requestTimeEpoch": 1569555024662,
"requestId": "dc58012d-438c-4298-bc8d-75dd4bee8562",
"identity": {
"cognitoIdentityPoolId": null,
"accountId": null,
"cognitoIdentityId": null,
"caller": null,
"sourceIp": "119.254.228.2",
"principalOrgId": null,
"accessKey": null,
"cognitoAuthenticationType": null,
"cognitoAuthenticationProvider": null,
"userArn": null,
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36",
"user": null
},
"domainName": "oq7all40u3.execute-api.cn-north-1.amazonaws.com.cn",
"apiId": "oq7all40u3"
},
"body": null,
"isBase64Encoded": false
}
三、參數格式為路徑參數
eg:傳入參數123456 方式
https://oq7all40u3.execute-api.cn-north-1.amazonaws.com.cn/test/test/123456
需要使用代理資源{proxy+}
