refacto: nest axum templates routes

This commit is contained in:
2024-08-04 18:34:42 +02:00
parent 699978ad5e
commit a82e43ce7f
4 changed files with 35 additions and 20 deletions

View File

@ -1,7 +1,20 @@
use askama::Template;
use askama_axum::IntoResponse;
use axum::{routing, Router};
#[derive(Template)]
#[template(path = "hello.html")]
pub struct HelloResponse {
struct HelloResponse {
pub name: String,
}
async fn hello() -> impl IntoResponse {
HelloResponse {
name: "Theo".to_string(),
}.into_response()
}
pub fn get_routes() -> Router {
Router::new()
.route("/", routing::get(hello))
}