From a61c4072e5a1dc5edddf5299d1523696bb881c90 Mon Sep 17 00:00:00 2001 From: Chikke Srujan Date: Wed, 7 Aug 2024 16:28:54 +0530 Subject: [PATCH] remove try --- crates/router/src/core/payment_link.rs | 11 +++++++---- crates/router/src/services/authentication.rs | 14 -------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rs index 4199a0ae2682..2fc57f62f49e 100644 --- a/crates/router/src/core/payment_link.rs +++ b/crates/router/src/core/payment_link.rs @@ -26,7 +26,7 @@ use crate::{ get_payment_link_config_value, get_payment_link_config_value_based_on_priority, headers::ACCEPT_LANGUAGE, routes::SessionState, - services::{self, authentication::try_get_header_value_by_key}, + services::{self, authentication::get_header_value_by_key}, types::{ api::payment_link::PaymentLinkResponseExt, domain, @@ -257,7 +257,8 @@ pub async fn initiate_secure_payment_link_flow( payment_id: String, request_headers: &header::HeaderMap, ) -> RouterResponse { - let locale = try_get_header_value_by_key(ACCEPT_LANGUAGE.into(), request_headers); + let locale = get_header_value_by_key(ACCEPT_LANGUAGE.into(), request_headers)? + .map(|val| val.to_string()); let (payment_link, payment_link_details, payment_link_config) = form_payment_link_data( &state, merchant_account, @@ -354,7 +355,8 @@ pub async fn initiate_payment_link_flow( payment_id: String, request_headers: &header::HeaderMap, ) -> RouterResponse { - let locale = try_get_header_value_by_key(ACCEPT_LANGUAGE.into(), request_headers); + let locale = get_header_value_by_key(ACCEPT_LANGUAGE.into(), request_headers)? + .map(|val| val.to_string()); let (_, payment_details, payment_link_config) = form_payment_link_data( &state, merchant_account, @@ -637,7 +639,8 @@ pub async fn get_payment_link_status( payment_id: String, request_headers: &header::HeaderMap, ) -> RouterResponse { - let locale = try_get_header_value_by_key(ACCEPT_LANGUAGE.into(), request_headers); + let locale = get_header_value_by_key(ACCEPT_LANGUAGE.into(), request_headers)? + .map(|val| val.to_string()); let db = &*state.store; let payment_intent = db .find_payment_intent_by_payment_id_merchant_id( diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs index ddb0d56db0c1..a82306fd1331 100644 --- a/crates/router/src/services/authentication.rs +++ b/crates/router/src/services/authentication.rs @@ -1525,20 +1525,6 @@ pub fn get_header_value_by_key(key: String, headers: &HeaderMap) -> RouterResult .transpose() } -pub fn try_get_header_value_by_key(key: String, headers: &HeaderMap) -> Option { - headers - .get(key.clone()) - .map(|value| { - value.to_str().map(|str| str.to_owned()).map_err(|err| { - logger::warn!("Could not convert {} header to string: {}", key, err); - err - }) - }) - .transpose() - .ok() - .flatten() -} - pub fn get_jwt_from_authorization_header(headers: &HeaderMap) -> RouterResult<&str> { headers .get(crate::headers::AUTHORIZATION)