[AWS DA] API Gateway: Mapping Templates

[AWS DA] API Gateway: Mapping Templates

 

What does it means?

For example, if we have setup a API Gateway, REST API, GET method point to a Lambda function with no proxy intergration which return:

{
  "statusCode": 200,
  "body": "\"Hello from Lambda! mapping\""
}

[Notice]: If we set with Proxy integration, we will only get the body from the response "Hello from Lambda! mapping"; Mapping template can NOT be used with proxy

If no proxy, then we get whatever Lambda function return to us.

Now we want to mask the response field to a different one:

[AWS DA] API Gateway: Mapping Templates

In this case, we can use Mapping Templates.

 

To create a Mapping Template for a Method:

[AWS DA] API Gateway: Mapping Templates

[AWS DA] API Gateway: Mapping Templates

Here we renamed `statusCode` & `body`, and added new field `newField`.

 

[AWS DA] API Gateway: Mapping Templates

 

[AWS DA] API Gateway: Mapping Templates

 

[AWS DA] API Gateway: Mapping Templates

上一篇:Django Template file 'fileName' not found less


下一篇:Shell脚本攻略04-玩转文件描述符及重定向