Skip to content

Commit f40ff2c

Browse files
committed
fmt, clippy
markdown fix
1 parent 2dffdbe commit f40ff2c

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

lambda-http/src/deserializer.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,15 @@ mod tests {
145145

146146
#[test]
147147
fn test_deserialize_vpc_lattice() {
148-
let data =
149-
include_bytes!("../../lambda-events/src/fixtures/example-vpc-lattice-v2-request.json");
148+
let data = include_bytes!("../../lambda-events/src/fixtures/example-vpc-lattice-v2-request.json");
150149

151150
let req: LambdaRequest = serde_json::from_slice(data).expect("failed to deserialize vpc lattice data");
152151
match req {
153152
LambdaRequest::VpcLatticeV2(req) => {
154-
assert_eq!("arn:aws:vpc-lattice:ap-southeast-2:123456789012:targetgroup/tg-6d0ecf831eec9f09", req.request_context.target_group_arn);
153+
assert_eq!(
154+
"arn:aws:vpc-lattice:ap-southeast-2:123456789012:targetgroup/tg-6d0ecf831eec9f09",
155+
req.request_context.target_group_arn
156+
);
155157
}
156158
other => panic!("unexpected request variant: {other:?}"),
157159
}

lambda-http/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//#![deny(warnings)]
44
//! Enriches the `lambda` crate with [`http`](https://github.com/hyperium/http)
55
//! types targeting AWS
6-
//! [ALB](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html),
7-
//! [API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html),
8-
//! [VPC Lattice](https://docs.aws.amazon.com/vpc-lattice/latest/ug/lambda-functions.html) REST and HTTP API lambda integrations.
6+
//! * [ALB](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html)
7+
//! * [API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html) REST and HTTP API lambda integrations
8+
//! * [VPC Lattice](https://docs.aws.amazon.com/vpc-lattice/latest/ug/lambda-functions.html)
99
//!
1010
//! This crate abstracts over all of these trigger events using standard [`http`](https://github.com/hyperium/http) types minimizing the mental overhead
1111
//! of understanding the nuances and variation between trigger details allowing you to focus more on your application while also giving you to the maximum flexibility to

lambda-http/src/request.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ fn into_websocket_request(ag: ApiGatewayWebsocketProxyRequest) -> http::Request<
349349
req
350350
}
351351

352-
353352
#[cfg(feature = "vpc_lattice")]
354353
fn into_vpc_lattice_request(vlr: VpcLatticeRequestV2) -> http::Request<Body> {
355354
let http_method = vlr.method;
@@ -373,8 +372,7 @@ fn into_vpc_lattice_request(vlr: VpcLatticeRequestV2) -> http::Request<Body> {
373372

374373
let mut req = builder
375374
.body(
376-
vlr
377-
.body
375+
vlr.body
378376
.as_deref()
379377
.map_or_else(Body::default, |b| Body::from_maybe_encoded(base64, b)),
380378
)
@@ -840,7 +838,7 @@ mod tests {
840838

841839
let body_str = match request.body() {
842840
Body::Text(s) => s.as_str(),
843-
_ => ""
841+
_ => "",
844842
};
845843

846844
assert_eq!(body_str, "All is good");
@@ -853,7 +851,9 @@ mod tests {
853851
assert!(uri.contains("state=prod"), "unexpected uri: {uri}");
854852

855853
// Ensure this is an VPC Lattice request
856-
let req_context = request.request_context_ref().expect("Request is missing RequestContext");
854+
let req_context = request
855+
.request_context_ref()
856+
.expect("Request is missing RequestContext");
857857
assert!(
858858
matches!(req_context, &RequestContext::VpcLattice(_)),
859859
"expected Vpc lattice context, got {req_context:?}"
@@ -873,7 +873,7 @@ mod tests {
873873

874874
let body_array = match request.body() {
875875
Body::Binary(s) => s.as_slice(),
876-
_ => &[]
876+
_ => &[],
877877
};
878878

879879
assert_eq!(body_array, *b"All is good");
@@ -886,7 +886,9 @@ mod tests {
886886
assert!(uri.to_string().contains("state=prod"));
887887

888888
// Ensure this is an VPC Lattice request
889-
let req_context = request.request_context_ref().expect("Request is missing RequestContext");
889+
let req_context = request
890+
.request_context_ref()
891+
.expect("Request is missing RequestContext");
890892
assert!(
891893
matches!(req_context, &RequestContext::VpcLattice(_)),
892894
"expected Vpc lattice context, got {req_context:?}"
@@ -924,7 +926,9 @@ mod tests {
924926
assert_eq!(basic_headers_as_big_string, Some("curl/7.68.0".to_string()));
925927

926928
// Ensure this is an VPC Lattice request
927-
let req_context = request.request_context_ref().expect("Request is missing RequestContext");
929+
let req_context = request
930+
.request_context_ref()
931+
.expect("Request is missing RequestContext");
928932
assert!(
929933
matches!(req_context, &RequestContext::VpcLattice(_)),
930934
"expected Vpc lattice context, got {req_context:?}"

lambda-http/src/response.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use aws_lambda_events::alb::AlbTargetGroupResponse;
77
use aws_lambda_events::apigw::ApiGatewayProxyResponse;
88
#[cfg(feature = "apigw_http")]
99
use aws_lambda_events::apigw::ApiGatewayV2httpResponse;
10+
use aws_lambda_events::encodings::Body;
1011
#[cfg(feature = "vpc_lattice")]
1112
use aws_lambda_events::vpc_lattice::VpcLatticeResponse;
12-
use aws_lambda_events::encodings::Body;
1313
use encoding_rs::Encoding;
1414
use http::{
1515
header::{CONTENT_ENCODING, CONTENT_TYPE},
@@ -170,7 +170,7 @@ impl LambdaResponse {
170170

171171
response.body = body;
172172
response.is_base64_encoded = is_base64_encoded;
173-
response.status_code = status_code as u16;
173+
response.status_code = status_code;
174174
response.headers = headers;
175175
// Today, this implementation doesn't provide any additional fields
176176
#[cfg(feature = "catch-all-fields")]
@@ -633,10 +633,7 @@ mod tests {
633633
.expect("failed to create response"),
634634
);
635635
let json = serde_json::to_string(&res).expect("failed to serialize to json");
636-
assert_eq!(
637-
json,
638-
r#"{"isBase64Encoded":true,"statusCode":200,"body":"aGVsbG8="}"#
639-
);
636+
assert_eq!(json, r#"{"isBase64Encoded":true,"statusCode":200,"body":"aGVsbG8="}"#);
640637
}
641638

642639
#[test]

0 commit comments

Comments
 (0)