feat(metrics): add response metrics (#1263)

This commit is contained in:
Nishant Joshi
2023-05-25 15:04:13 +05:30
committed by GitHub
parent 5e90a369db
commit 4ebd26f27e
9 changed files with 134 additions and 19 deletions

View File

@ -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>>