mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-18 19:12:54 +00:00
- Add auth module import to main.rs - Add AuthConfig initialization from environment in main function - Add auth_config field to AppState struct - Add auth_middleware layer to protected routes - Move health check, credit check, deduct, balance, and usage recording to public routes (no auth required for packet-gateway integration) - Move add credit, subscriber management, rating plans, monitoring, and engine
52 lines
978 B
Rust
52 lines
978 B
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::auth::AuthConfig;
|
|
|
|
#[derive(Clone)]
|
|
pub struct AppState {
|
|
pub charging_engine: std::sync::Arc<crate::charging::ChargingEngine>,
|
|
pub auth_config: AuthConfig,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct CreditCheckRequest {
|
|
pub bytes_requested: u64,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
pub struct CreditCheckResponse {
|
|
pub allowed: bool,
|
|
pub remaining_bytes: i64,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct DeductRequest {
|
|
pub bytes_used: u64,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct AddCreditRequest {
|
|
pub bytes_to_add: u64,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
pub struct BalanceResponse {
|
|
pub ip: String,
|
|
pub balance_bytes: i64,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
pub struct HealthResponse {
|
|
pub status: String,
|
|
pub timestamp: chrono::DateTime<chrono::Utc>,
|
|
}
|
|
|
|
impl Default for HealthResponse {
|
|
fn default() -> Self {
|
|
Self {
|
|
status: "OK".to_string(),
|
|
timestamp: chrono::Utc::now(),
|
|
}
|
|
}
|
|
}
|