21 lines
488 B
Rust
21 lines
488 B
Rust
use askama::Template;
|
|
use axum::{
|
|
http::HeaderMap,
|
|
response::{Html, IntoResponse},
|
|
};
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "index.html")]
|
|
struct IndexTemplate;
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "partials/index.html")]
|
|
struct IndexPartialTemplate;
|
|
|
|
pub async fn home(headers: HeaderMap) -> impl IntoResponse {
|
|
if headers.contains_key("hx-request") {
|
|
Html(IndexPartialTemplate.render().unwrap())
|
|
} else {
|
|
Html(IndexTemplate.render().unwrap())
|
|
}
|
|
}
|