I'm using this to return some image data from a lambda:
let resp = AlbTargetGroupResponse {
status_code: 200,
body: Some(Body::Binary(buf)),
headers: HeaderMap::new(),
is_base64_encoded: true,
multi_value_headers: HeaderMap::new(),
status_description: Some(String::from("200 OK")),
};
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 to true. However, it might make sense to drop the is_base64_encoded field entirely, and auto-generate that based on the type of body:
- If
body is Body::Text -> is_base64_encoded = false.
- If
body is Body::Binary -> is_base64_encoded = true.
- If
body is Body::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?
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_encodedshould be set totrue. However, it might make sense to drop theis_base64_encodedfield entirely, and auto-generate that based on the type ofbody:bodyisBody::Text->is_base64_encoded = false.bodyisBody::Binary->is_base64_encoded = true.bodyisBody::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?