mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
refactor: Replace Bach with Application on every naming (#292)
This commit is contained in:
@ -320,7 +320,7 @@ async fn handle_response(
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub enum BachResponse<R> {
|
||||
pub enum ApplicationResponse<R> {
|
||||
Json(R),
|
||||
StatusOk,
|
||||
TextPlain(String),
|
||||
@ -329,11 +329,11 @@ pub enum BachResponse<R> {
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Serialize)]
|
||||
pub struct BachRedirectResponse {
|
||||
pub struct ApplicationRedirectResponse {
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
impl From<&storage::PaymentAttempt> for BachRedirectResponse {
|
||||
impl From<&storage::PaymentAttempt> for ApplicationRedirectResponse {
|
||||
fn from(payment_attempt: &storage::PaymentAttempt) -> Self {
|
||||
Self {
|
||||
url: format!(
|
||||
@ -376,7 +376,7 @@ pub async fn server_wrap_util<'a, 'b, U, T, Q, F, Fut>(
|
||||
payload: T,
|
||||
func: F,
|
||||
api_auth: &dyn auth::AuthenticateAndFetch<U>,
|
||||
) -> RouterResult<BachResponse<Q>>
|
||||
) -> RouterResult<ApplicationResponse<Q>>
|
||||
where
|
||||
F: Fn(&'b AppState, U, T) -> Fut,
|
||||
Fut: Future<Output = RouterResponse<Q>>,
|
||||
@ -402,7 +402,7 @@ pub async fn server_wrap<'a, 'b, T, U, Q, F, Fut>(
|
||||
) -> HttpResponse
|
||||
where
|
||||
F: Fn(&'b AppState, U, T) -> Fut,
|
||||
Fut: Future<Output = RouterResult<BachResponse<Q>>>,
|
||||
Fut: Future<Output = RouterResult<ApplicationResponse<Q>>>,
|
||||
Q: Serialize + Debug + 'a,
|
||||
T: Debug,
|
||||
{
|
||||
@ -415,7 +415,7 @@ where
|
||||
logger::info!(tag = ?Tag::BeginRequest);
|
||||
|
||||
let res = match server_wrap_util(state, request, payload, func, api_auth).await {
|
||||
Ok(BachResponse::Json(response)) => match serde_json::to_string(&response) {
|
||||
Ok(ApplicationResponse::Json(response)) => match serde_json::to_string(&response) {
|
||||
Ok(res) => http_response_json(res),
|
||||
Err(_) => http_response_err(
|
||||
r#"{
|
||||
@ -425,19 +425,21 @@ where
|
||||
}"#,
|
||||
),
|
||||
},
|
||||
Ok(BachResponse::StatusOk) => http_response_ok(),
|
||||
Ok(BachResponse::TextPlain(text)) => http_response_plaintext(text),
|
||||
Ok(BachResponse::JsonForRedirection(response)) => match serde_json::to_string(&response) {
|
||||
Ok(res) => http_redirect_response(res, response),
|
||||
Err(_) => http_response_err(
|
||||
r#"{
|
||||
Ok(ApplicationResponse::StatusOk) => http_response_ok(),
|
||||
Ok(ApplicationResponse::TextPlain(text)) => http_response_plaintext(text),
|
||||
Ok(ApplicationResponse::JsonForRedirection(response)) => {
|
||||
match serde_json::to_string(&response) {
|
||||
Ok(res) => http_redirect_response(res, response),
|
||||
Err(_) => http_response_err(
|
||||
r#"{
|
||||
"error": {
|
||||
"message": "Error serializing response from connector"
|
||||
}
|
||||
}"#,
|
||||
),
|
||||
},
|
||||
Ok(BachResponse::Form(response)) => build_redirection_form(&response)
|
||||
),
|
||||
}
|
||||
}
|
||||
Ok(ApplicationResponse::Form(response)) => build_redirection_form(&response)
|
||||
.respond_to(request)
|
||||
.map_into_boxed_body(),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user