awslabs / aws-lambda-rust-runtime

A Rust runtime for AWS Lambda
Apache License 2.0
3.31k stars 338 forks source link

feat: ergonomic improvements to HTTP payload deserialization #921

Closed mlaota closed 1 week ago

mlaota commented 2 weeks ago

📬 Issue #, if available:

917

✍️ Description of changes: Ergonomic improvements to HTTP payload deserialization with intent-driven helper methods (json and form_url_encoded are the initial implementations). Details in RFC (#917).

Note: there was a bug in RequestPayloadExt::payload where if the content-type header was present but the body was empty, it would try to parse it anyways, resulting in a PayloadError. The bug was fixed when I updated the function to delegate to json and form_urlencoded. I added a couple unit tests in this PR for that scenario to ensure the behavior doesn't regress if its implementation drifts from the new functions in the future.

🔏 By submitting this pull request