Created
December 31, 2021 13:54
-
-
Save leegilmorecode/e2898511fd15fda5938910e4515d097a to your computer and use it in GitHub Desktop.
CDK API Gateway setting for path based caching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // integrate the lambda to the method - GET /blogs | |
| blogs.addMethod( | |
| "GET", | |
| new apigw.LambdaIntegration(listBlogsHandler, { | |
| proxy: true, | |
| allowTestInvoke: true, | |
| }) | |
| ); | |
| // integrate the lambda to the method - GET /blog/{id} | |
| const blog: apigw.Resource = blogs.addResource("{id}"); | |
| blog.addMethod( | |
| "GET", | |
| new apigw.LambdaIntegration(getBlogHandler, { | |
| proxy: true, | |
| allowTestInvoke: true, | |
| // ensure that our caching is done on the id path parameter | |
| cacheKeyParameters: ["method.request.path.id"], | |
| cacheNamespace: "blogId", | |
| requestParameters: { | |
| "integration.request.path.id": "method.request.path.id", | |
| }, | |
| }), | |
| { | |
| requestParameters: { | |
| "method.request.path.id": true, | |
| }, | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment