Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

Add default to http_serde::header_map::deserialize #35

Merged
merged 2 commits into from
Mar 17, 2021

Conversation

dacut
Copy link
Contributor

@dacut dacut commented Mar 16, 2021

The Go SDK typically has omitEmpty for Rust's http::HeaderMap entries, and services like ALB omit them when they're not present. However, without a default parameter to the #[serde()] annotation, deserialization fails when they're missing instead of the desired behavior of producing an empty HeaderMap.

This changes #[serde(deserialize_with = "http_serde::header_map::deserialize")] annotations to #[serde(deserialize_with = "http_serde::header_map::deserialize", default)] so we get the desired behavior. A test is also added (in aws_lambda_events/src/custom_serde.rs -- feel free to suggest a better place if there is one) to verify the correctness of this change.

@dacut
Copy link
Contributor Author

dacut commented Mar 16, 2021

This has been verified in my own Lambda function behind an ALB, FWIW.

Copy link
Contributor

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

@LegNeato LegNeato merged commit bb96fd7 into calavera:master Mar 17, 2021
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants