From 1c5cb023517e541b47bebc69b943ded86fccc204 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Wed, 4 May 2022 04:46:38 -0700 Subject: [PATCH] fix: address clippy warnings --- src/azure_function/logger.rs | 8 ++++---- src/ipn_handler.rs | 28 +++++++++++++--------------- src/main.rs | 7 +++---- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/azure_function/logger.rs b/src/azure_function/logger.rs index efc7ee3..7937ddc 100644 --- a/src/azure_function/logger.rs +++ b/src/azure_function/logger.rs @@ -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; @@ -70,7 +70,7 @@ 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; @@ -78,7 +78,7 @@ impl LogMiddleware { 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; diff --git a/src/ipn_handler.rs b/src/ipn_handler.rs index 7651991..d3c30ee 100644 --- a/src/ipn_handler.rs +++ b/src/ipn_handler.rs @@ -119,21 +119,19 @@ pub async fn ipn_handler(mut req: AppRequest) -> tide::Result { } // 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); diff --git a/src/main.rs b/src/main.rs index 01a779d..952f96a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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.