- docker-compose: 下线 Python backend/config-service,切换至 config-service-rs - archive: 归档 legacy Python 目录至 archive/python/* - services: 新增/更新 common-contracts、api-gateway、各 provider、report-generator-service、config-service-rs - data-persistence-service: API/system 模块与模型/DTO 调整 - frontend: 更新 useApi 与 API 路由 - docs: 更新路线图并勾选光荣退役 - cleanup: 移除 data-distance-service 占位测试
40 lines
985 B
Rust
40 lines
985 B
Rust
mod api;
|
|
mod config;
|
|
mod error;
|
|
mod state;
|
|
mod persistence;
|
|
|
|
use crate::config::AppConfig;
|
|
use crate::error::Result;
|
|
use crate::state::AppState;
|
|
use tracing::info;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
// Initialize logging
|
|
tracing_subscriber::fmt()
|
|
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
|
|
.init();
|
|
|
|
info!("Starting api-gateway service...");
|
|
|
|
// Load configuration
|
|
let config = AppConfig::load().map_err(|e| error::AppError::Configuration(e.to_string()))?;
|
|
let port = config.server_port;
|
|
|
|
// Initialize application state
|
|
let app_state = AppState::new(config).await?;
|
|
|
|
// Create the Axum router
|
|
let app = api::create_router(app_state);
|
|
|
|
// Start the HTTP server
|
|
let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", port))
|
|
.await
|
|
.unwrap();
|
|
info!("HTTP server listening on port {}", port);
|
|
axum::serve(listener, app).await.unwrap();
|
|
|
|
Ok(())
|
|
}
|