summaryrefslogtreecommitdiff
path: root/src/handlers.rs
diff options
context:
space:
mode:
authorNaz <ndpm13@ch-naseem.com>2025-09-15 14:50:08 +0100
committerNaz <ndpm13@ch-naseem.com>2025-09-15 15:08:15 +0100
commit8b5a71dd3a490718540a7e9d48da2a220256a628 (patch)
treeb1e029fad2a636dabcf053192ded8542e530b3d1 /src/handlers.rs
parentc53617755ea9f98c8c8e36901db90e19e827a483 (diff)
✨feat: dirty commit bringing basic functionality
Diffstat (limited to 'src/handlers.rs')
-rw-r--r--src/handlers.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
new file mode 100644
index 0000000..b235c84
--- /dev/null
+++ b/src/handlers.rs
@@ -0,0 +1,28 @@
+use askama::Template;
+use axum::{extract::State, response::Html};
+
+use crate::{
+ Result,
+ config::Config,
+ models::{Bookmarks, Section},
+};
+
+#[derive(Template)]
+#[template(path = "index.html")]
+pub struct MyTemplate {
+ bookmarks: Vec<Section>,
+}
+
+pub async fn handler(State(config): State<Config>) -> Result<Html<String>> {
+ let bookmarks = std::fs::read_to_string(config.bookmarks_file)?;
+
+ let bookmarks: Bookmarks = serde_json::from_str(&bookmarks)?;
+
+ let template = MyTemplate {
+ bookmarks: bookmarks.sections,
+ };
+
+ let html = template.render()?;
+
+ Ok(Html(html))
+}