add: api routes

This commit is contained in:
trisua 2025-08-24 12:29:36 -04:00
parent d7ee379a9a
commit ce9ce4f635
16 changed files with 1119 additions and 109 deletions

25
src/routes/pages/misc.rs Normal file
View file

@ -0,0 +1,25 @@
use crate::{State, routes::default_context};
use axum::{
Extension,
response::{Html, IntoResponse},
};
use tetratto_core::model::Error;
pub async fn not_found_request(Extension(data): Extension<State>) -> impl IntoResponse {
let (ref data, ref tera, ref build_code) = *data.read().await;
let mut ctx = default_context(&data.0.0, &build_code);
ctx.insert(
"error",
&Error::GeneralNotFound("page".to_string()).to_string(),
);
return Html(tera.render("error.lisp", &ctx).unwrap());
}
pub async fn index_request(Extension(data): Extension<State>) -> impl IntoResponse {
let (ref data, ref tera, ref build_code) = *data.read().await;
Html(
tera.render("index.lisp", &default_context(&data.0.0, &build_code))
.unwrap(),
)
}

7
src/routes/pages/mod.rs Normal file
View file

@ -0,0 +1,7 @@
pub mod misc;
use axum::routing::{Router, get};
pub fn routes() -> Router {
Router::new().route("/", get(misc::index_request))
}