mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 12:15:40 +08:00
feat(metrics): add response metrics (#1263)
This commit is contained in:
@ -20,10 +20,28 @@ use crate::{
|
||||
types::storage,
|
||||
utils::OptionExt,
|
||||
};
|
||||
|
||||
pub trait AuthInfo {
|
||||
fn get_merchant_id(&self) -> Option<&str>;
|
||||
}
|
||||
|
||||
impl AuthInfo for () {
|
||||
fn get_merchant_id(&self) -> Option<&str> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl AuthInfo for storage::MerchantAccount {
|
||||
fn get_merchant_id(&self) -> Option<&str> {
|
||||
Some(&self.merchant_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait AuthenticateAndFetch<T, A>
|
||||
where
|
||||
A: AppStateInfo,
|
||||
T: AuthInfo,
|
||||
{
|
||||
async fn authenticate_and_fetch(
|
||||
&self,
|
||||
@ -303,7 +321,7 @@ impl ClientSecretFetch for api_models::cards_info::CardsInfoRequest {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn jwt_auth_or<'a, T, A: AppStateInfo>(
|
||||
pub fn jwt_auth_or<'a, T: AuthInfo, A: AppStateInfo>(
|
||||
default_auth: &'a dyn AuthenticateAndFetch<T, A>,
|
||||
headers: &HeaderMap,
|
||||
) -> Box<&'a dyn AuthenticateAndFetch<T, A>>
|
||||
|
||||
Reference in New Issue
Block a user