mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
chore: add lints in workspace cargo config (#223)
This commit is contained in:
@ -22,12 +22,12 @@ use crate::{
|
||||
payments,
|
||||
},
|
||||
db::StorageInterface,
|
||||
logger, routes,
|
||||
logger,
|
||||
routes::AppState,
|
||||
types::{
|
||||
self, api,
|
||||
storage::{self, enums},
|
||||
ErrorResponse, Response,
|
||||
ErrorResponse,
|
||||
},
|
||||
utils::{self, OptionExt},
|
||||
};
|
||||
@ -36,7 +36,7 @@ pub type BoxedConnectorIntegration<'a, T, Req, Resp> =
|
||||
Box<&'a (dyn ConnectorIntegration<T, Req, Resp> + Send + Sync)>;
|
||||
|
||||
pub trait ConnectorIntegrationAny<T, Req, Resp>: Send + Sync + 'static {
|
||||
fn get_connector_integration(&self) -> BoxedConnectorIntegration<T, Req, Resp>;
|
||||
fn get_connector_integration(&self) -> BoxedConnectorIntegration<'_, T, Req, Resp>;
|
||||
}
|
||||
|
||||
impl<S, T, Req, Resp> ConnectorIntegrationAny<T, Req, Resp> for S
|
||||
@ -86,7 +86,7 @@ pub trait ConnectorIntegration<T, Req, Resp>: ConnectorIntegrationAny<T, Req, Re
|
||||
fn handle_response(
|
||||
&self,
|
||||
data: &types::RouterData<T, Req, Resp>,
|
||||
_res: Response,
|
||||
_res: types::Response,
|
||||
) -> CustomResult<types::RouterData<T, Req, Resp>, errors::ConnectorError>
|
||||
where
|
||||
T: Clone,
|
||||
@ -185,7 +185,7 @@ where
|
||||
pub(crate) async fn call_connector_api(
|
||||
state: &AppState,
|
||||
request: Request,
|
||||
) -> CustomResult<Result<Response, Response>, errors::ApiClientError> {
|
||||
) -> CustomResult<Result<types::Response, types::Response>, errors::ApiClientError> {
|
||||
let current_time = Instant::now();
|
||||
|
||||
let response = send_request(state, request).await;
|
||||
@ -256,7 +256,7 @@ async fn send_request(
|
||||
#[instrument(skip_all)]
|
||||
async fn handle_response(
|
||||
response: CustomResult<reqwest::Response, errors::ApiClientError>,
|
||||
) -> CustomResult<Result<Response, Response>, errors::ApiClientError> {
|
||||
) -> CustomResult<Result<types::Response, types::Response>, errors::ApiClientError> {
|
||||
response
|
||||
.map(|response| async {
|
||||
logger::info!(?response);
|
||||
@ -272,7 +272,7 @@ async fn handle_response(
|
||||
.into_report()
|
||||
.change_context(errors::ApiClientError::ResponseDecodingFailed)
|
||||
.attach_printable("Error while waiting for response")?;
|
||||
Ok(Ok(Response {
|
||||
Ok(Ok(types::Response {
|
||||
response,
|
||||
status_code,
|
||||
}))
|
||||
@ -308,7 +308,7 @@ async fn handle_response(
|
||||
};
|
||||
Err(report!(error).attach_printable("Client error response received"))
|
||||
*/
|
||||
Ok(Err(Response {
|
||||
Ok(Err(types::Response {
|
||||
response: bytes,
|
||||
status_code,
|
||||
}))
|
||||
@ -408,14 +408,14 @@ pub enum AuthFlow {
|
||||
Merchant,
|
||||
}
|
||||
|
||||
pub(crate) fn get_auth_flow(auth_type: &MerchantAuthentication) -> AuthFlow {
|
||||
pub(crate) fn get_auth_flow(auth_type: &MerchantAuthentication<'_>) -> AuthFlow {
|
||||
match auth_type {
|
||||
MerchantAuthentication::ApiKey => AuthFlow::Merchant,
|
||||
_ => AuthFlow::Client,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_auth_type(request: &HttpRequest) -> RouterResult<MerchantAuthentication> {
|
||||
pub(crate) fn get_auth_type(request: &HttpRequest) -> RouterResult<MerchantAuthentication<'_>> {
|
||||
let api_key = get_api_key(request).change_context(errors::ApiErrorResponse::Unauthorized)?;
|
||||
if api_key.starts_with("pk_") {
|
||||
Ok(MerchantAuthentication::PublishableKey)
|
||||
@ -426,17 +426,17 @@ pub(crate) fn get_auth_type(request: &HttpRequest) -> RouterResult<MerchantAuthe
|
||||
|
||||
#[instrument(skip(request, payload, state, func))]
|
||||
pub(crate) async fn server_wrap_util<'a, 'b, T, Q, F, Fut>(
|
||||
state: &'b routes::AppState,
|
||||
state: &'b AppState,
|
||||
request: &'a HttpRequest,
|
||||
payload: T,
|
||||
func: F,
|
||||
api_authentication: ApiAuthentication<'a>,
|
||||
) -> RouterResult<BachResponse<Q>>
|
||||
where
|
||||
F: Fn(&'b routes::AppState, storage::MerchantAccount, T) -> Fut,
|
||||
F: Fn(&'b AppState, storage::MerchantAccount, T) -> Fut,
|
||||
Fut: Future<Output = RouterResponse<Q>>,
|
||||
Q: Serialize + Debug + 'a,
|
||||
T: std::fmt::Debug,
|
||||
T: Debug,
|
||||
{
|
||||
let merchant_account = match api_authentication {
|
||||
ApiAuthentication::Merchant(merchant_auth) => {
|
||||
@ -455,7 +455,7 @@ where
|
||||
fields(request_method, request_url_path)
|
||||
)]
|
||||
pub(crate) async fn server_wrap<'a, 'b, A, T, Q, F, Fut>(
|
||||
state: &'b routes::AppState,
|
||||
state: &'b AppState,
|
||||
request: &'a HttpRequest,
|
||||
payload: T,
|
||||
func: F,
|
||||
@ -463,10 +463,10 @@ pub(crate) async fn server_wrap<'a, 'b, A, T, Q, F, Fut>(
|
||||
) -> HttpResponse
|
||||
where
|
||||
A: Into<ApiAuthentication<'a>> + Debug,
|
||||
F: Fn(&'b routes::AppState, storage::MerchantAccount, T) -> Fut,
|
||||
F: Fn(&'b AppState, storage::MerchantAccount, T) -> Fut,
|
||||
Fut: Future<Output = RouterResult<BachResponse<Q>>>,
|
||||
Q: Serialize + Debug + 'a,
|
||||
T: std::fmt::Debug,
|
||||
T: Debug,
|
||||
{
|
||||
let api_authentication = api_authentication.into();
|
||||
let request_method = request.method().as_str();
|
||||
@ -594,9 +594,9 @@ pub async fn authenticate_connector<'a>(
|
||||
}
|
||||
|
||||
pub(crate) fn get_auth_type_and_check_client_secret<P>(
|
||||
req: &actix_web::HttpRequest,
|
||||
req: &HttpRequest,
|
||||
payload: P,
|
||||
) -> RouterResult<(P, MerchantAuthentication)>
|
||||
) -> RouterResult<(P, MerchantAuthentication<'_>)>
|
||||
where
|
||||
P: Authenticate,
|
||||
{
|
||||
@ -608,7 +608,7 @@ where
|
||||
}
|
||||
|
||||
pub(crate) async fn authenticate_eph_key<'a>(
|
||||
req: &'a actix_web::HttpRequest,
|
||||
req: &'a HttpRequest,
|
||||
store: &dyn StorageInterface,
|
||||
customer_id: String,
|
||||
) -> RouterResult<MerchantAuthentication<'a>> {
|
||||
@ -748,7 +748,7 @@ pub fn build_redirection_form(form: &RedirectForm) -> maud::Markup {
|
||||
}
|
||||
}
|
||||
|
||||
(maud::PreEscaped(r#"<script type="text/javascript"> var frm = document.getElementById("payment_form"); window.setTimeout(function () { frm.submit(); }, 500); </script>"#))
|
||||
(PreEscaped(r#"<script type="text/javascript"> var frm = document.getElementById("payment_form"); window.setTimeout(function () { frm.submit(); }, 500); </script>"#))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user