This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
AlbTargetGroupResponse automatically base64 encodes data #49
Labels
good first issue
Good for newcomers
Comments
Hmmm, I'll have to think about this. I think we can support this case but it will take some refactoring. |
Somewhat related: If when returning `Some(Body::Empty)` from a lambda the ALB then yields 502. Returning `None` works though. If I understand the source correctly, `Some(Body::Empty)` is converted to `body: null`, but `None` merely results in the field being omitted when serialising.
I'm using this in a helper for now (I takes `body: Body` as input):
```rust
let (is_base64_encoded, body) = match body {
Body::Empty => (false, None), // Body::Empty results in ALB returning 502.
Body::Text(_) => (false, Some(body)),
Body::Binary(_) => (true, Some(body)),
};
```
|
Is the go code correct in this case? Does it have |
It does not. I've sent a patch via aws/aws-lambda-go#408. |
Go code is now correct: aws/aws-lambda-go#408 I think it's a matter of re-generating the auto-generated code? |
The Alb code is no longer under the generator, so we can make any adjustments we'd like to improve the experience of using that type, like the automatic encoding selection that you mention in the description. Feel free to make changes in that module: https://github.com/LegNeato/aws-lambda-events/blob/master/aws_lambda_events/src/alb/mod.rs |
# for free
to subscribe to this conversation on GitHub.
Already have an account?
#.
I'm using this to return some image data from a lambda:
It appears that when using
body: Some(Body::Binary(buf))
, this library automatically encodes the payload in base64.In this case,
is_base64_encoded
should be set totrue
. However, it might make sense to drop theis_base64_encoded
field entirely, and auto-generate that based on the type ofbody
:body
isBody::Text
->is_base64_encoded = false
.body
isBody::Binary
->is_base64_encoded = true
.body
isBody::Empty
-> irrelevant...?Given that most of the code around this is auto-generated, I'm not sure if this is even possible.
Are there any fields that are auto-generated based on other's value? Do you think my suggestion makes sense, or is it simpler to just add a note in the docs explaining that binary content is always base64 encoded?
The text was updated successfully, but these errors were encountered: