Enum lambda_http::Body [−][src]
Expand description
Representation of http request and response bodies as supported by API Gateway and ALBs.
These come in three flavors
Empty( no body )Text( text data )Binary( binary data )
Body types can be Deref and AsRef’d into [u8] types much like the hyper crate
Examples
Body types are inferred with From implementations.
Text
Types like String, str whose type reflects
text produce Body::Text variants
assert!(match lambda_http::Body::from("text") { lambda_http::Body::Text(_) => true, _ => false })
Binary
Types like Vec<u8> and &[u8] whose types reflect raw bytes produce Body::Binary variants
assert!(match lambda_http::Body::from("text".as_bytes()) { lambda_http::Body::Binary(_) => true, _ => false })
Binary responses bodies will automatically get based64 encoded to meet API Gateway’s response expectations.
Empty
The unit type ( () ) whose type represents an empty value produces Body::Empty variants
assert!(match lambda_http::Body::from(()) { lambda_http::Body::Empty => true, _ => false })
For more information about API Gateway’s body types, refer to this documentation.
Variants
An empty body
A body containing string data
Tuple Fields of Text
0: StringA body containing binary data