mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-18 11:02:54 +00:00
feat: Add Clone derive to AppState and cast balance values to i64 in API responses
- Add Clone derive to AppState struct - Cast remaining_bytes to i64 in CreditCheckResponse - Cast balance_bytes to i64 in BalanceResponse
This commit is contained in:
@@ -10,6 +10,7 @@ use tracing::{info, warn};
|
||||
use crate::errors::{ChargingError, ChargingResult, validate_ip, validate_bytes, ErrorContext};
|
||||
use crate::models::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub charging_engine: std::sync::Arc<crate::charging::ChargingEngine>,
|
||||
}
|
||||
@@ -54,7 +55,7 @@ pub async fn check_credit(
|
||||
|
||||
Ok(Json(CreditCheckResponse {
|
||||
allowed,
|
||||
remaining_bytes: remaining,
|
||||
remaining_bytes: remaining as i64,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -116,7 +117,7 @@ pub async fn get_balance(
|
||||
|
||||
Ok(Json(BalanceResponse {
|
||||
ip,
|
||||
balance_bytes: balance,
|
||||
balance_bytes: balance as i64,
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user