28 lines
659 B
Rust
28 lines
659 B
Rust
|
mod templates;
|
||
|
|
||
|
use std::path::Path;
|
||
|
|
||
|
use askama_axum::IntoResponse;
|
||
|
use templates::{hello::HelloResponse, index::GetIndexResponse};
|
||
|
use tower_http::services::ServeDir;
|
||
|
|
||
|
async fn root() -> impl IntoResponse {
|
||
|
return GetIndexResponse {}.into_response();
|
||
|
}
|
||
|
|
||
|
async fn hello() -> impl IntoResponse {
|
||
|
return HelloResponse {
|
||
|
name: "Theo".to_string(),
|
||
|
}
|
||
|
.into_response();
|
||
|
}
|
||
|
|
||
|
pub fn get_router(assets_path: &Path) -> axum::Router {
|
||
|
let router = axum::Router::new()
|
||
|
.nest_service("/assets", ServeDir::new(assets_path))
|
||
|
.route("/", axum::routing::get(root))
|
||
|
.route("/hello", axum::routing::get(hello));
|
||
|
|
||
|
router
|
||
|
}
|