mylloon.fr/src/routes/index.rs

26 lines
624 B
Rust
Raw Normal View History

2023-04-09 19:02:06 +02:00
use actix_web::{get, web, HttpResponse, Responder};
2023-04-11 10:45:25 +02:00
use cached::proc_macro::once;
2023-04-09 19:02:06 +02:00
use ramhorns::Content;
2023-02-08 20:49:05 +01:00
2023-04-11 10:03:22 +02:00
use crate::{config::Config, template::Infos};
2023-02-09 11:19:53 +01:00
2023-02-08 20:49:05 +01:00
#[get("/")]
2023-04-09 19:02:06 +02:00
pub async fn page(config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(get_page(config.get_ref().clone()))
2023-02-08 20:49:05 +01:00
}
2023-02-08 22:14:57 +01:00
2023-04-09 19:02:06 +02:00
#[derive(Content)]
2023-02-09 10:45:59 +01:00
struct IndexTemplate {}
2023-02-08 22:14:57 +01:00
2023-04-11 10:45:25 +02:00
#[once(time = 60)]
2023-04-14 11:30:47 +02:00
pub fn get_page(config: Config) -> String {
2023-04-11 10:16:46 +02:00
config.tmpl.render(
"index.html",
IndexTemplate {},
Infos {
page_title: Some("Mylloon".to_string()),
page_desc: Some("Page principale".to_string()),
},
)
2023-02-08 22:14:57 +01:00
}