taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

lib.rs (1557B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2025, 2026 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU Affero General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
     12 
     13   You should have received a copy of the GNU Affero General Public License along with
     14   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 
     17 use std::sync::Arc;
     18 
     19 use sqlx::PgPool;
     20 use taler_api::api::{Router, TalerRouter as _};
     21 use taler_common::config::Config;
     22 
     23 use crate::{api::CyclosApi, config::ServeCfg};
     24 
     25 pub mod api;
     26 pub mod config;
     27 pub mod constants;
     28 pub mod cyclos_api;
     29 pub mod db;
     30 pub mod dev;
     31 pub mod notification;
     32 pub mod payto;
     33 pub mod setup;
     34 pub mod worker;
     35 
     36 pub async fn run_serve(cfg: &Config, pool: PgPool) -> anyhow::Result<()> {
     37     let cfg = ServeCfg::parse(cfg)?;
     38     let api = Arc::new(CyclosApi::start(pool, cfg.root, cfg.payto, cfg.currency).await);
     39     let mut router = Router::new();
     40     if let Some(cfg) = cfg.wire_gateway {
     41         router = router.wire_gateway(api.clone(), cfg.auth.method());
     42     }
     43     if let Some(cfg) = cfg.revenue {
     44         router = router.revenue(api, cfg.auth.method());
     45     }
     46     router.serve(cfg.serve, None).await?;
     47     Ok(())
     48 }