This commit is contained in:
2025-11-15 00:34:04 +01:00
parent 38ed2842ff
commit 260671f3ad
18 changed files with 338 additions and 25 deletions

View File

@@ -1,13 +1,29 @@
use axum::Router;
use std::sync::Arc;
use axum::{Router, middleware};
use crate::app::http::api;
use crate::app::http::api::core;
use crate::app::http::api::{channel, core, message, server};
use crate::app::http::middleware::auth_middleware;
use crate::app::http::middleware::auth_middleware::auth_middleware;
use crate::db::context::DbContext;
pub fn configure_routes() -> Router {
let api_router = Router::new();
#[derive(Clone)]
pub struct AppState {
db: Arc<DbContext>
}
pub fn configure_routes(db_context: Arc<DbContext>) -> Router {
let app_state = Arc::new(AppState {
db: db_context.clone()
});
let api_router = Router::new()
.nest("/server/", server::routes())
.nest("/channel/", channel::routes())
.nest("/message/", message::routes())
.with_state(app_state);
Router::new()
.merge(core::routes())
.nest("/api", api_router )
.nest("/api", api_router)
.layer(middleware::from_fn_with_state(db_context.clone(), auth_middleware))
}