mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 05:17:02 +08:00
refactor: AppState trait for utility functions (#499)
This commit is contained in:
committed by
GitHub
parent
a2921ff835
commit
9381a37f8f
@ -25,7 +25,7 @@ use crate::{
|
||||
},
|
||||
db::StorageInterface,
|
||||
logger,
|
||||
routes::AppState,
|
||||
routes::{app::AppStateInfo, AppState},
|
||||
services::authentication as auth,
|
||||
types::{
|
||||
self, api,
|
||||
@ -384,18 +384,19 @@ pub enum AuthFlow {
|
||||
}
|
||||
|
||||
#[instrument(skip(request, payload, state, func, api_auth))]
|
||||
pub async fn server_wrap_util<'a, 'b, U, T, Q, F, Fut>(
|
||||
state: &'b AppState,
|
||||
pub async fn server_wrap_util<'a, 'b, A, U, T, Q, F, Fut>(
|
||||
state: &'b A,
|
||||
request: &'a HttpRequest,
|
||||
payload: T,
|
||||
func: F,
|
||||
api_auth: &dyn auth::AuthenticateAndFetch<U>,
|
||||
api_auth: &dyn auth::AuthenticateAndFetch<U, A>,
|
||||
) -> RouterResult<ApplicationResponse<Q>>
|
||||
where
|
||||
F: Fn(&'b AppState, U, T) -> Fut,
|
||||
F: Fn(&'b A, U, T) -> Fut,
|
||||
Fut: Future<Output = RouterResponse<Q>>,
|
||||
Q: Serialize + Debug + 'a,
|
||||
T: Debug,
|
||||
A: AppStateInfo,
|
||||
{
|
||||
let auth_out = api_auth
|
||||
.authenticate_and_fetch(request.headers(), state)
|
||||
@ -407,18 +408,19 @@ where
|
||||
skip(request, payload, state, func, api_auth),
|
||||
fields(request_method, request_url_path)
|
||||
)]
|
||||
pub async fn server_wrap<'a, 'b, T, U, Q, F, Fut>(
|
||||
state: &'b AppState,
|
||||
pub async fn server_wrap<'a, 'b, A, T, U, Q, F, Fut>(
|
||||
state: &'b A,
|
||||
request: &'a HttpRequest,
|
||||
payload: T,
|
||||
func: F,
|
||||
api_auth: &dyn auth::AuthenticateAndFetch<U>,
|
||||
api_auth: &dyn auth::AuthenticateAndFetch<U, A>,
|
||||
) -> HttpResponse
|
||||
where
|
||||
F: Fn(&'b AppState, U, T) -> Fut,
|
||||
F: Fn(&'b A, U, T) -> Fut,
|
||||
Fut: Future<Output = RouterResult<ApplicationResponse<Q>>>,
|
||||
Q: Serialize + Debug + 'a,
|
||||
T: Debug,
|
||||
A: AppStateInfo,
|
||||
{
|
||||
let request_method = request.method().as_str();
|
||||
let url_path = request.path();
|
||||
|
||||
Reference in New Issue
Block a user