feat: Implement a new layered architecture for the QR generator, integrating Axum, Maud, and HTMX, and updating documentation.

This commit is contained in:
2025-12-30 03:28:03 +01:00
parent 286e10160f
commit 9f12d44489
25 changed files with 2713 additions and 536 deletions

View File

@@ -0,0 +1,28 @@
use crate::application::generate_qr::GenerateQrUseCase;
use crate::domain::qr::QrOptions;
use crate::infrastructure::http::views::{index_page, qr_component};
use axum::{
extract::{Query, State},
response::IntoResponse,
};
use std::collections::HashMap;
use std::sync::Arc;
pub async fn index() -> impl IntoResponse {
index_page()
}
pub async fn generate(
State(use_case): State<Arc<GenerateQrUseCase>>,
Query(params): Query<HashMap<String, String>>,
) -> impl IntoResponse {
let data = params.get("data").cloned().unwrap_or_default();
// Simple options for now, can be extended to parse from params
let options = QrOptions::default();
match use_case.execute(data, options).await {
Ok(image_data) => qr_component(&image_data).into_response(),
Err(e) => format!("<div class='error'>Error: {}</div>", e).into_response(),
}
}