test route

This commit is contained in:
Mylloon 2023-04-11 01:52:54 +02:00
parent 3f17609b0c
commit 2dd4995479
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 33 additions and 0 deletions

View file

@ -20,6 +20,9 @@ mod networks;
#[path = "routes/portfolio.rs"]
mod portfolio;
#[path = "routes/portfolio2.rs"]
mod portfolio2;
#[path = "routes/contrib.rs"]
mod contrib;
@ -50,6 +53,7 @@ async fn main() -> io::Result<()> {
.service(agreements::sitemap)
.service(networks::page)
.service(portfolio::page)
.service(portfolio2::page)
.service(contrib::page)
.service(Files::new("/", config.static_location.clone()))
.default_service(web::to(not_found::page))

29
src/routes/portfolio2.rs Normal file
View file

@ -0,0 +1,29 @@
use actix_web::{get, web, HttpResponse, Responder};
use ramhorns::Content;
use crate::{config::Config, template::File};
#[get("/portfolio2")]
pub async fn page(config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(get_page(config.get_ref().clone()))
}
#[derive(Content)]
struct PortfolioTemplate {
page_title: String,
bots_app: Vec<File>,
persos_app: Vec<File>,
univ_content: String,
}
pub fn get_page(config: Config) -> std::string::String {
config.tmpl.render(
"portfolio2.html",
PortfolioTemplate {
page_title: "Portfolio".to_string(),
bots_app: Vec::with_capacity(0),
persos_app: Vec::with_capacity(0),
univ_content: String::new(),
},
)
}