29 lines
741 B
Rust
29 lines
741 B
Rust
|
use actix_web::{get, web, HttpResponse, Responder};
|
||
|
use cached::proc_macro::once;
|
||
|
use ramhorns::Content;
|
||
|
|
||
|
use crate::config::Config;
|
||
|
|
||
|
#[get("/blog")]
|
||
|
pub async fn index(config: web::Data<Config>) -> impl Responder {
|
||
|
HttpResponse::Ok().body(get_index(config.get_ref().clone()))
|
||
|
}
|
||
|
|
||
|
#[derive(Content)]
|
||
|
struct BlogIndexTemplate {}
|
||
|
|
||
|
#[once(time = 60)]
|
||
|
pub fn get_index(_config: Config) -> String {
|
||
|
String::from("Salut pour tous")
|
||
|
}
|
||
|
|
||
|
#[get("/blog/{id}")]
|
||
|
pub async fn page(path: web::Path<(u32,)>, config: web::Data<Config>) -> impl Responder {
|
||
|
HttpResponse::Ok().body(get_page(path.into_inner().0, config.get_ref().clone()))
|
||
|
}
|
||
|
|
||
|
#[once(time = 60)]
|
||
|
pub fn get_page(id: u32, _config: Config) -> String {
|
||
|
format!("Salut pour {id}")
|
||
|
}
|