Skip to content

Commit

Permalink
fix: serialize AlbTargetGroupRequest::query_string_parameters value…
Browse files Browse the repository at this point in the history
… to string

fix awslabs#954
  • Loading branch information
DiscreteTom committed Jan 3, 2025
1 parent f69280e commit e29dc51
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lambda-events/src/event/alb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct AlbTargetGroupRequest {
#[serde(default)]
pub path: Option<String>,
#[serde(default)]
#[serde(serialize_with = "query_map::serde::aws_api_gateway_v1::serialize_query_string_parameters")]
pub query_string_parameters: QueryMap,
#[serde(default)]
pub multi_value_query_string_parameters: QueryMap,
Expand Down Expand Up @@ -70,6 +71,7 @@ pub struct AlbTargetGroupResponse {
#[cfg(test)]
mod test {
use super::*;
use serde_json::Value;

#[test]
#[cfg(feature = "alb")]
Expand All @@ -91,6 +93,19 @@ mod test {
assert_eq!(parsed, reparsed);
}

#[test]
#[cfg(feature = "alb")]
fn ensure_alb_lambda_target_request_query_string_parameter_value_is_string() {
let data = include_bytes!("../../fixtures/example-alb-lambda-target-request-headers-only.json");
let parsed: AlbTargetGroupRequest = serde_json::from_slice(data).unwrap();
let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: Value = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(
reparsed["queryStringParameters"]["key"],
Value::String("hello".to_string())
);
}

#[test]
#[cfg(feature = "alb")]
fn example_alb_lambda_target_response() {
Expand Down

0 comments on commit e29dc51

Please sign in to comment.