2024-07-23 20:08:45 +02:00
|
|
|
use std::path::Path;
|
|
|
|
|
2024-08-10 16:59:36 +02:00
|
|
|
use askama_axum::Template;
|
2024-08-04 18:34:42 +02:00
|
|
|
use axum::http::{StatusCode, Uri};
|
2024-07-23 20:08:45 +02:00
|
|
|
use tower_http::services::ServeDir;
|
|
|
|
|
2024-08-23 18:45:43 +02:00
|
|
|
mod menu;
|
|
|
|
mod pages;
|
|
|
|
|
2024-08-04 18:34:42 +02:00
|
|
|
async fn fallback(uri: Uri) -> (StatusCode, String) {
|
|
|
|
(StatusCode::NOT_FOUND, format!("No route for {uri}"))
|
2024-07-23 20:08:45 +02:00
|
|
|
}
|
|
|
|
|
2024-08-04 18:34:42 +02:00
|
|
|
#[derive(Template)]
|
|
|
|
#[template(path = "index.html")]
|
2024-08-10 16:59:36 +02:00
|
|
|
pub struct GetIndexTemplate;
|
2024-08-04 18:34:42 +02:00
|
|
|
|
2024-08-10 16:59:36 +02:00
|
|
|
async fn root() -> GetIndexTemplate {
|
|
|
|
GetIndexTemplate {}
|
2024-07-23 20:08:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_router(assets_path: &Path) -> axum::Router {
|
2024-08-04 18:34:42 +02:00
|
|
|
axum::Router::new()
|
2024-07-23 20:08:45 +02:00
|
|
|
.nest_service("/assets", ServeDir::new(assets_path))
|
|
|
|
.route("/", axum::routing::get(root))
|
2024-08-23 18:45:43 +02:00
|
|
|
.merge(pages::get_routes())
|
2024-08-04 18:34:42 +02:00
|
|
|
.fallback(fallback)
|
2024-07-23 20:08:45 +02:00
|
|
|
}
|