refactor: add renderer middleware + base of roles and authorizations

This commit is contained in:
Matthieu Bessat 2024-11-08 23:38:54 +01:00
parent 40b892391a
commit c277ab3bd9
30 changed files with 374 additions and 137 deletions

View file

@ -1,17 +1,16 @@
use axum::{extract::State, response::{Html, IntoResponse}};
use axum::{response::IntoResponse, Extension};
use axum_macros::debug_handler;
use minijinja::context;
use crate::server::AppState;
use crate::renderer::TemplateRenderer;
#[debug_handler]
pub async fn home(
State(app_state): State<AppState>
Extension(renderer): Extension<TemplateRenderer>
) -> impl IntoResponse {
Html(
app_state.templating_env.get_template("pages/home.html").unwrap()
.render(context!())
.unwrap()
renderer.render(
"pages/home",
context!()
)
}