[core] Allow specifying additional request templates in proxy method #876
Labels
feature-request
A feature should be added or improved
needs-triage
The issue or PR still needs to be triaged
I would like to request for the ability to specify additional content-type mappings for request templates in the
ApiGatewayToSqs
construct. Internally, this is using theaddProxyMethodToApiResource
method in the core library. The method hardcodes theAWSIntegration
props, allowing just a single request template forapplication/json
.Use Case
I am using the
ApiGatewayToSqs
construct, but the caller of the endpoint will be making requests withContent-Type
oftext/plain
. Currently this results in a 415 error response, as it is configured with a body passthrough value ofNone
.Proposed Solution
The method already accepts a parameter called
requestTemplate
, but:To avoid breaking changes, I can propose adding a new parameter to the
addProxyMethodToApiResource
method, something likeadditionalRequestTemplates
, which accepts a map of content-type to mapping.A similar thing can be done for
integrationResponses
, so that we can close the request/response loop.For my specific issue, these changes would be accompanied by a similar change in the
ApiGatewayToSqs
construct to allow the additional request template to be passed in.Workaround
I have worked around this by manipulating the low level objects in CDK, but it's unwieldy to say the least.
Other
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: