28 lines
770 B
Rust
28 lines
770 B
Rust
// src/state.rs
|
|
|
|
use crate::db;
|
|
use crate::api::BankingClients;
|
|
use sqlx::PgPool;
|
|
|
|
/// Общее состояние приложения, доступное во всех handlers
|
|
#[derive(Clone)]
|
|
pub struct AppState {
|
|
pub db_pool: PgPool,
|
|
pub banking_clients: BankingClients,
|
|
}
|
|
|
|
impl AppState {
|
|
pub async fn new() -> Self {
|
|
let db_pool = db::init_pool().await;
|
|
println!("✅ Database connection pool created successfully.");
|
|
|
|
// FIX: Add .await and handle the potential error
|
|
let banking_clients = BankingClients::new().await.expect("Failed to initialize banking clients");
|
|
println!("✅ Banking API clients initialized.");
|
|
|
|
Self {
|
|
db_pool,
|
|
banking_clients,
|
|
}
|
|
}
|
|
}
|