Description
Describe the bug
When using spring-cloud-function-adapter-aws, in the event of requesting a missing REST resource I’m struggling to understand how to return a 404 status code with an empty payload.
I’ve landed on Function<APIGatewayProxyRequestEvent, Message<String>>
which allows me to specify a "statusCode" header and an empty string as the body, but I’m wondering if there’s a more idiomatic approach to this in spring-cloud-function that allows me to return an empty body (as opposed to an empty string)?
I’ve tried a few options, such as Function<APIGatewayProxyRequestEvent, Owner>
and Function<APIGatewayProxyRequestEvent, Message<Owner>>
. The former doesn’t let you control statusCode and headers that are returned, and the latter doesn’t let you return a Message with a null payload.
Ideally, I’d just like to return a APIGatewayProxyResponseEvent, which I’d have full control of and would bypass all post-function response conversion.
This issue was originally raised in SO - https://stackoverflow.com/questions/68465552/how-to-handle-a-404-response-with-spring-cloud-function-and-aws
Sample
I have my example in GitHub, with the function and a test which reproduces the issue
Lambda Config
Lambda Test
Thanks, Ben