Skip to content

Commit

Permalink
fix: address clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishrock123 committed May 4, 2022
1 parent 3f91ebd commit 1c5cb02
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/azure_function/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ impl LogMiddleware {
logger.log(format!("Internal error. message: {:?}, error_type: {:?}, status: {}, duration: {:?}",
error,
error.type_name(),
format!("{} - {}", status as u16, status.canonical_reason()),
format_args!("{} - {}", status as u16, status.canonical_reason()),
start.elapsed(),
)).await;
} else {
logger
.log(format!(
"Internal error. status: {}, duration: {:?}",
format!("{} - {}", status as u16, status.canonical_reason()),
format_args!("{} - {}", status as u16, status.canonical_reason()),
start.elapsed(),
))
.await;
Expand All @@ -70,15 +70,15 @@ impl LogMiddleware {
"Client error. message: {:?}, error_type: {:?}, status: {}, duration: {:?}",
error,
error.type_name(),
format!("{} - {}", status as u16, status.canonical_reason()),
format_args!("{} - {}", status as u16, status.canonical_reason()),
start.elapsed(),
))
.await;
} else {
logger
.log(format!(
"Client error. status: {}, duration: {:?}",
format!("{} - {}", status as u16, status.canonical_reason()),
format_args!("{} - {}", status as u16, status.canonical_reason()),
start.elapsed(),
))
.await;
Expand Down
28 changes: 13 additions & 15 deletions src/ipn_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,19 @@ pub async fn ipn_handler(mut req: AppRequest) -> tide::Result<Response> {
}

// Attempt to deserialize the IPN message.
let ipn_transaction_message: IPNTransationMessage;
match serde_qs::from_str(&ipn_transaction_message_raw) {
Ok(msg) => {
ipn_transaction_message = msg;
}
Err(error) => {
return Err(tide::Error::from_str(
StatusCode::InternalServerError,
format!(
"(Full IPN Details) Invalid IPN: unparseable IPN: \"{}\" - error: {:?}",
ipn_transaction_message_raw, error
),
));
}
}
let ipn_transaction_message: IPNTransationMessage =
match serde_qs::from_str(&ipn_transaction_message_raw) {
Ok(msg) => msg,
Err(error) => {
return Err(tide::Error::from_str(
StatusCode::InternalServerError,
format!(
"(Full IPN Details) Invalid IPN: unparseable IPN: \"{}\" - error: {:?}",
ipn_transaction_message_raw, error
),
));
}
};

if let Some(payment_date) = ipn_transaction_message.payment_date {
info!(logger, "Payment Timestamp: {}", payment_date);
Expand Down
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ async fn main() -> Result<()> {

// PayPal
let paypal_sandbox = env::var("PAYPAL_SANDBOX").is_ok();
let paypal_base_url;
if paypal_sandbox {
let paypal_base_url = if paypal_sandbox {
warn!("SANDBOX: Using PayPal sandbox environment");
paypal_base_url = Url::parse("https://ipnpb.sandbox.paypal.com/")?;
Url::parse("https://ipnpb.sandbox.paypal.com/")?
} else {
paypal_base_url = Url::parse("https://ipnpb.paypal.com/")?;
Url::parse("https://ipnpb.paypal.com/")?
};

// Set up re-useable api clients for efficiency & ergonomics.
Expand Down

0 comments on commit 1c5cb02

Please sign in to comment.