This commit is contained in:
2025-10-25 23:46:01 +02:00
parent d7aefc4110
commit 62cadbcfa0
8 changed files with 1061 additions and 55 deletions
+17 -1
View File
@@ -2,12 +2,15 @@ use axum::http::HeaderValue;
use axum::{
extract::DefaultBodyLimit,
middleware,
response::Json,
routing::{delete, get, patch, post},
Router,
};
use std::sync::Arc;
use tower_http::cors::{AllowOrigin, CorsLayer};
use utoipa::OpenApi;
use crate::{auth::AuthenticatedUser, state::AppState};
use crate::{auth::AuthenticatedUser, openapi::ApiDoc, state::AppState};
pub mod auth;
pub mod correspondents;
@@ -128,9 +131,22 @@ pub fn create_router(state: AppState) -> Router<()> {
.nest("/api/assets", assets_routes)
.layer(middleware::from_extractor_with_state::<AuthenticatedUser, _>(protected_state));
let openapi_arc = Arc::new(ApiDoc::openapi());
let docs_route = Router::new().route(
"/api/docs/openapi.json",
get({
let spec = openapi_arc.clone();
move || {
let spec = spec.clone();
async move { Json((*spec).clone()) }
}
}),
);
Router::new()
.merge(download_routes)
.merge(protected_routes)
.merge(docs_route)
.nest("/api/auth", auth_routes)
.route("/api/health", get(health::health_check))
.with_state(state)