Unclear how to configure binary content types #1402
-
Hi. For serverless lambdas in micronaut-aws, the I'm trying to figure out how to tell I see the It seems to check the I was hoping to do something like this in my controller: @Get("some/endpoint")
public HttpResponse<String> someEndpoint() {
var gzippedBytes = ...;
return HttpResponse.ok(gzippedBytes)
.contentType(MediaType.APPLICATION_JSON);
} And then set
Above taken from: https://docs.amazonaws.cn/en_us/apigateway/latest/developerguide/lambda-proxy-binary-media.html The actual problem I'm trying to solve: Our lambda return payloads exceed 6MiB - the maximum Lambda payloads allowed by AWS. Gzipping helps us reduce our payloads a lot (our data is mostly textual). However we're struggling to understand how to tell micronaut to treat the return payload as binary, so it will create the JSON object above and pass that on to AWS. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've managed to make it work by setting the Although I've tried also doing For now this solution works for me. |
Beta Was this translation helpful? Give feedback.
I've managed to make it work by setting the
contentType
to"application/zip"
. It seems to trigger the config here:micronaut-aws/function-aws-api-proxy/src/main/java/io/micronaut/function/aws/proxy/AbstractLambdaContainerHandler.java
Line 110 in 1c52abe
Although I've tried also doing
config.addBinaryContentTypes("application/json");
, that didn't work. Haven't had a chance to debug that yet.For now this solution works for me.