mylloon.fr/src/routes/index.rs
Mylloon ec90edfc3d
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
give url to templates
2023-04-29 14:13:22 +02:00

27 lines
724 B
Rust

use actix_web::{get, web, HttpRequest, HttpResponse, Responder};
use cached::proc_macro::once;
use crate::{config::Config, misc::utils::get_url, template::Infos};
#[get("/")]
pub async fn page(req: HttpRequest, config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(build_page(
config.get_ref().to_owned(),
get_url(req.connection_info()),
))
}
#[once(time = 60)]
pub fn build_page(config: Config, url: String) -> String {
println!("{url}");
config.tmpl.render(
"index.html",
(),
Infos {
page_title: config.fc.fullname,
page_desc: Some("Page principale".into()),
page_kw: None,
url,
},
)
}