Skip to content

Commit 6954e3b

Browse files
committed
fix(lambda-events): change VPC Lattice method/path to Option<T>
1 parent 9494cb8 commit 6954e3b

2 files changed

Lines changed: 29 additions & 15 deletions

File tree

lambda-events/src/event/vpc_lattice/v1.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,19 @@ use crate::{
2121
// we note that V1 requests are snake cased UNLIKE v2 which are camel cased
2222
#[serde(rename_all = "snake_case")]
2323
pub struct VpcLatticeRequestV1 {
24-
/// The url path for the request
25-
pub raw_path: String,
24+
/// The url path for the request.
25+
/// Present only if the protocol is HTTP, HTTPS, or gRPC.
26+
#[serde(default)]
27+
#[serde(skip_serializing_if = "Option::is_none")]
28+
pub raw_path: Option<String>,
2629

27-
/// The HTTP method of the request
28-
#[serde(with = "http_method")]
29-
pub method: Method,
30+
/// The HTTP method of the request.
31+
/// Present only if the protocol is HTTP, HTTPS, or gRPC.
32+
#[serde(deserialize_with = "http_method::deserialize_optional")]
33+
#[serde(serialize_with = "http_method::serialize_optional")]
34+
#[serde(skip_serializing_if = "Option::is_none")]
35+
#[serde(default)]
36+
pub method: Option<Method>,
3037

3138
/// HTTP headers of the request (V1 uses comma-separated strings for multi-values)
3239
#[serde(deserialize_with = "deserialize_comma_separated_headers", default)]
@@ -64,8 +71,8 @@ mod test {
6471
let data = include_bytes!("../../fixtures/example-vpc-lattice-v1-request.json");
6572
let parsed: VpcLatticeRequestV1 = serde_json::from_slice(data).unwrap();
6673

67-
assert_eq!("/api/product", parsed.raw_path);
68-
assert_eq!("POST", parsed.method);
74+
assert_eq!(Some("/api/product".to_string()), parsed.raw_path);
75+
assert_eq!(Some(Method::POST), parsed.method);
6976
assert_eq!(
7077
"curl/7.68.0",
7178
parsed.headers.get_all("user-agent").iter().next().unwrap()

lambda-events/src/event/vpc_lattice/v2.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@ pub struct VpcLatticeRequestV2 {
2222
#[serde(default = "default_version")]
2323
pub version: String,
2424

25-
/// The url path for the request
26-
pub path: String,
27-
28-
/// The HTTP method of the request
29-
#[serde(with = "http_method")]
30-
pub method: Method,
25+
/// The url path for the request.
26+
/// Present only if the protocol is HTTP, HTTPS, or gRPC.
27+
#[serde(default)]
28+
#[serde(skip_serializing_if = "Option::is_none")]
29+
pub path: Option<String>,
30+
31+
/// The HTTP method of the request.
32+
/// Present only if the protocol is HTTP, HTTPS, or gRPC.
33+
#[serde(deserialize_with = "http_method::deserialize_optional")]
34+
#[serde(serialize_with = "http_method::serialize_optional")]
35+
#[serde(skip_serializing_if = "Option::is_none")]
36+
#[serde(default)]
37+
pub method: Option<Method>,
3138

3239
/// HTTP headers of the request (VPC Lattice V2 uses arrays for multi-values)
3340
#[serde(default, deserialize_with = "deserialize_headers")]
@@ -160,8 +167,8 @@ mod test {
160167
let data = include_bytes!("../../fixtures/example-vpc-lattice-v2-request.json");
161168
let parsed: VpcLatticeRequestV2 = serde_json::from_slice(data).unwrap();
162169

163-
assert_eq!("/health", parsed.path);
164-
assert_eq!("GET", parsed.method);
170+
assert_eq!(Some("/health".to_string()), parsed.path);
171+
assert_eq!(Some(Method::GET), parsed.method);
165172
assert_eq!(
166173
"curl/7.68.0",
167174
parsed.headers.get_all("user-agent").iter().next().unwrap()

0 commit comments

Comments
 (0)