Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed cargo clippy warnings #359

Merged
merged 2 commits into from
Oct 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions lambda-http/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ where
T: Default + Deserialize<'de>,
{
let opt = Option::deserialize(deserializer)?;
Ok(opt.unwrap_or_else(T::default))
Ok(opt.unwrap_or_default())
}

/// Converts LambdaRequest types into `http::Request<Body>` types
Expand Down Expand Up @@ -397,7 +397,7 @@ impl<'a> From<LambdaRequest<'a>> for http::Request<Body> {
headers
.get("X-Forwarded-Proto")
.and_then(|val| val.to_str().ok())
.unwrap_or_else(|| "https"),
.unwrap_or("https"),
headers
.get(http::header::HOST)
.and_then(|val| val.to_str().ok())
Expand Down Expand Up @@ -445,7 +445,7 @@ impl<'a> From<LambdaRequest<'a>> for http::Request<Body> {
headers
.get("X-Forwarded-Proto")
.and_then(|val| val.to_str().ok())
.unwrap_or_else(|| "https"),
.unwrap_or("https"),
headers
.get(http::header::HOST)
.and_then(|val| val.to_str().ok())
Expand Down Expand Up @@ -508,7 +508,7 @@ impl<'a> From<LambdaRequest<'a>> for http::Request<Body> {
headers
.get("X-Forwarded-Proto")
.and_then(|val| val.to_str().ok())
.unwrap_or_else(|| "https"),
.unwrap_or("https"),
headers
.get(http::header::HOST)
.and_then(|val| val.to_str().ok())
Expand Down Expand Up @@ -609,7 +609,7 @@ mod tests {
// https://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-api-gateway-request
// note: file paths are relative to the directory of the crate at runtime
let result = from_reader(File::open("tests/data/apigw_proxy_request.json").expect("expected file"));
assert!(result.is_ok(), format!("event was not parsed as expected {:?}", result));
assert!(result.is_ok(), "event was not parsed as expected {:?}", result);
}

#[test]
Expand All @@ -620,7 +620,9 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
format!("event was not parsed as expected {:?} given {}", result, input)
"event was not parsed as expected {:?} given {}",
result,
input
);
let req = result.expect("failed to parse request");
assert_eq!(req.method(), "GET");
Expand All @@ -635,7 +637,9 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
format!("event was not parsed as expected {:?} given {}", result, input)
"event was not parsed as expected {:?} given {}",
result,
input
);
let req = result.expect("failed to parse request");
let cookie_header = req
Expand All @@ -658,7 +662,9 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
format!("event was not parsed as expected {:?} given {}", result, input)
"event was not parsed as expected {:?} given {}",
result,
input
);
let req = result.expect("failed to parse request");
assert_eq!(req.method(), "GET");
Expand All @@ -676,7 +682,9 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
format!("event was not parsed as expected {:?} given {}", result, input)
"event was not parsed as expected {:?} given {}",
result,
input
);
let req = result.expect("failed to parse request");
assert_eq!(req.method(), "GET");
Expand All @@ -691,7 +699,9 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
format!("event is was not parsed as expected {:?} given {}", result, input)
"event is was not parsed as expected {:?} given {}",
result,
input
);
let request = result.expect("failed to parse request");

Expand All @@ -712,7 +722,9 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
format!("event is was not parsed as expected {:?} given {}", result, input)
"event is was not parsed as expected {:?} given {}",
result,
input
);
let request = result.expect("failed to parse request");
assert!(!request.query_string_parameters().is_empty());
Expand Down