pub mod error; pub mod routes; pub mod state; pub mod ws; pub mod ws_protocol; use axum::Router; use std::sync::Arc; use tower_http::cors::{Any, CorsLayer}; use tower_http::trace::TraceLayer; pub use state::AppState; pub fn build_router(state: Arc) -> Router { let cors = CorsLayer::new() .allow_origin(Any) .allow_methods(Any) .allow_headers(Any); let api = routes::api_routes(); Router::new() .nest("/api", api) .route("/ws", axum::routing::get(ws::ws_handler)) .layer(cors) .layer(TraceLayer::new_for_http()) .with_state(state) }