config: added custom html insertion and separated name and title

This commit is contained in:
2025-12-01 18:54:09 +01:00
parent bdfa359702
commit 4045779947
2 changed files with 14 additions and 3 deletions
+6
View File
@@ -18,13 +18,17 @@ use tower_http::cors::{Any, CorsLayer};
#[derive(Debug, Deserialize)]
struct FieldDef {
name: String,
title: String,
description: String,
answer_type: String,
html_before: Option<String>,
html_after: Option<String>,
}
#[derive(Debug, Deserialize)]
struct AppConfig {
json_output: String,
submit_button: String,
fields: Vec<FieldDef>,
}
@@ -111,11 +115,13 @@ async fn render_form(State(state): State<AppState>) -> impl IntoResponse {
struct FormTemplate<'a> {
fields: &'a [FieldDef],
lang: &'a str,
submit_button: &'a str,
}
let tmpl = FormTemplate {
fields: &state.cfg.fields,
lang: "en",
submit_button: &state.cfg.submit_button,
};
match tmpl.render() {
Ok(html) => Html(html).into_response(),