summaryrefslogtreecommitdiff
path: root/src/handlers.rs
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2024-09-14 20:54:44 -0400
committerAdam T. Carpenter <atc@53hor.net>2024-09-14 20:54:44 -0400
commit18339f611fd17e1300593edd65adf7604a39ad72 (patch)
tree3f5238afaf4cac98640a50b9b7954be7bbfbe3f6 /src/handlers.rs
parent9f341d439f7aa5fd2365024169ead2d6bdc3210c (diff)
downloadcarpentertutoring-18339f611fd17e1300593edd65adf7604a39ad72.tar.xz
carpentertutoring-18339f611fd17e1300593edd65adf7604a39ad72.zip
feat: working rudimentary blog presentation
Diffstat (limited to 'src/handlers.rs')
-rw-r--r--src/handlers.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index db5cf7c..800d8f8 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -1,4 +1,5 @@
use askama::Template;
+use crate::views::post::PostView;
use crate::views::posts::PostsView;
use crate::posts::abstractions::repo::PostRepo;
use crate::views::policies::PoliciesTemplate;
@@ -8,7 +9,7 @@ use crate::views::about::AboutView;
use crate::tutors::abstractions::tutor_repo::TutorRepo;
use std::sync::Arc;
use axum::response::Html;
-use axum::extract::State;
+use axum::extract::{State, Path};
pub async fn about_handler(State(repo): State<Arc<impl TutorRepo>>) -> Html<String> {
let view = AboutView::with_tutors(repo.load());
@@ -32,3 +33,8 @@ pub async fn posts_handler(State(repo): State<Arc<impl PostRepo>>) -> Html<Strin
Html(view.render().unwrap())
}
+pub async fn post_handler(Path(post_id): Path<String>, State(repo): State<Arc<impl PostRepo>>) -> Html<String> {
+ let view = PostView::with_post(repo.by_id(&post_id));
+ Html(view.render().unwrap())
+}
+