34 lines
767 B
Rust
34 lines
767 B
Rust
use std::sync::Arc;
|
|
|
|
use askama::Template;
|
|
use axum::{
|
|
extract::State,
|
|
http::HeaderMap,
|
|
response::{Html, IntoResponse},
|
|
};
|
|
|
|
use crate::domain::AppState;
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "notfound.html")]
|
|
struct NotfoundTemplate<'a> {
|
|
tracks: &'a Vec<crate::domain::Track>,
|
|
}
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "partials/notfound.html")]
|
|
struct NotfoundPartialTemplate;
|
|
|
|
pub async fn notfound(headers: HeaderMap, state: State<Arc<AppState>>) -> impl IntoResponse {
|
|
if headers.contains_key("hx-request") {
|
|
Html(NotfoundPartialTemplate.render().unwrap())
|
|
} else {
|
|
Html(
|
|
NotfoundTemplate {
|
|
tracks: &state.mp_tracks,
|
|
}
|
|
.render()
|
|
.unwrap(),
|
|
)
|
|
}
|
|
}
|