generated from t/malachite
add: api routes
This commit is contained in:
parent
d7ee379a9a
commit
ce9ce4f635
16 changed files with 1119 additions and 109 deletions
25
src/routes/pages/misc.rs
Normal file
25
src/routes/pages/misc.rs
Normal 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
7
src/routes/pages/mod.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
pub mod misc;
|
||||
|
||||
use axum::routing::{Router, get};
|
||||
|
||||
pub fn routes() -> Router {
|
||||
Router::new().route("/", get(misc::index_request))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue