summaryrefslogtreecommitdiff
path: root/src/handlers.rs
diff options
context:
space:
mode:
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())
+}
+