mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
refactor(router): make utilities public (#396)
This commit is contained in:
@ -16,7 +16,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn create_merchant_api_key() -> String {
|
pub fn create_merchant_api_key() -> String {
|
||||||
let id = Uuid::new_v4().simple();
|
let id = Uuid::new_v4().simple();
|
||||||
match env::which() {
|
match env::which() {
|
||||||
Env::Development => format!("dev_{id}"),
|
Env::Development => format!("dev_{id}"),
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
pub(crate) mod api_error_response;
|
pub mod api_error_response;
|
||||||
pub(crate) mod error_handlers;
|
pub mod error_handlers;
|
||||||
pub(crate) mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
@ -12,8 +12,10 @@ pub use redis_interface::errors::RedisError;
|
|||||||
use router_env::opentelemetry::metrics::MetricsError;
|
use router_env::opentelemetry::metrics::MetricsError;
|
||||||
use storage_models::errors as storage_errors;
|
use storage_models::errors as storage_errors;
|
||||||
|
|
||||||
pub use self::api_error_response::ApiErrorResponse;
|
pub use self::{
|
||||||
pub(crate) use self::utils::{ConnectorErrorExt, StorageErrorExt};
|
api_error_response::ApiErrorResponse,
|
||||||
|
utils::{ConnectorErrorExt, StorageErrorExt},
|
||||||
|
};
|
||||||
use crate::services;
|
use crate::services;
|
||||||
pub type RouterResult<T> = CustomResult<T, ApiErrorResponse>;
|
pub type RouterResult<T> = CustomResult<T, ApiErrorResponse>;
|
||||||
pub type RouterResponse<T> = CustomResult<services::ApplicationResponse<T>, ApiErrorResponse>;
|
pub type RouterResponse<T> = CustomResult<services::ApplicationResponse<T>, ApiErrorResponse>;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use crate::{core::errors, logger};
|
use crate::{core::errors, logger};
|
||||||
|
|
||||||
pub(crate) trait StorageErrorExt {
|
pub trait StorageErrorExt {
|
||||||
fn to_not_found_response(
|
fn to_not_found_response(
|
||||||
self,
|
self,
|
||||||
not_found_response: errors::ApiErrorResponse,
|
not_found_response: errors::ApiErrorResponse,
|
||||||
@ -40,7 +40,7 @@ impl StorageErrorExt for error_stack::Report<errors::StorageError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait ConnectorErrorExt {
|
pub trait ConnectorErrorExt {
|
||||||
fn to_refund_failed_response(self) -> error_stack::Report<errors::ApiErrorResponse>;
|
fn to_refund_failed_response(self) -> error_stack::Report<errors::ApiErrorResponse>;
|
||||||
fn to_payment_failed_response(self) -> error_stack::Report<errors::ApiErrorResponse>;
|
fn to_payment_failed_response(self) -> error_stack::Report<errors::ApiErrorResponse>;
|
||||||
fn to_verify_failed_response(self) -> error_stack::Report<errors::ApiErrorResponse>;
|
fn to_verify_failed_response(self) -> error_stack::Report<errors::ApiErrorResponse>;
|
||||||
@ -115,7 +115,7 @@ impl ConnectorErrorExt for error_stack::Report<errors::ConnectorError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait RedisErrorExt {
|
pub trait RedisErrorExt {
|
||||||
fn to_redis_failed_response(self, key: &str) -> error_stack::Report<errors::StorageError>;
|
fn to_redis_failed_response(self, key: &str) -> error_stack::Report<errors::StorageError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
pub(crate) mod custom_serde;
|
pub mod custom_serde;
|
||||||
pub(crate) mod db_utils;
|
pub mod db_utils;
|
||||||
mod ext_traits;
|
pub mod ext_traits;
|
||||||
|
|
||||||
#[cfg(feature = "kv_store")]
|
#[cfg(feature = "kv_store")]
|
||||||
pub(crate) mod storage_partitioning;
|
pub mod storage_partitioning;
|
||||||
|
|
||||||
pub(crate) use common_utils::{
|
pub use common_utils::{
|
||||||
crypto,
|
crypto,
|
||||||
ext_traits::{ByteSliceExt, BytesExt, Encode, StringExt, ValueExt},
|
ext_traits::{ByteSliceExt, BytesExt, Encode, StringExt, ValueExt},
|
||||||
fp_utils::when,
|
fp_utils::when,
|
||||||
@ -15,7 +15,7 @@ use error_stack::{IntoReport, ResultExt};
|
|||||||
use nanoid::nanoid;
|
use nanoid::nanoid;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
|
|
||||||
pub(crate) use self::ext_traits::{OptionExt, ValidateCall};
|
pub use self::ext_traits::{OptionExt, ValidateCall};
|
||||||
use crate::{
|
use crate::{
|
||||||
consts,
|
consts,
|
||||||
core::errors::{self, RouterResult},
|
core::errors::{self, RouterResult},
|
||||||
|
|||||||
@ -6,7 +6,7 @@ use crate::{
|
|||||||
utils::when,
|
utils::when,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) trait OptionExt<T> {
|
pub trait OptionExt<T> {
|
||||||
fn check_value_present(&self, field_name: &str) -> RouterResult<()>;
|
fn check_value_present(&self, field_name: &str) -> RouterResult<()>;
|
||||||
|
|
||||||
fn get_required_value(self, field_name: &str) -> RouterResult<T>;
|
fn get_required_value(self, field_name: &str) -> RouterResult<T>;
|
||||||
|
|||||||
Reference in New Issue
Block a user