group contacts under an umbrella of aliases /c and /contact
All checks were successful
ci/woodpecker/push/publish Pipeline was successful

This commit is contained in:
Mylloon 2023-10-21 20:53:47 +02:00
parent 5cb04280d0
commit a37a5ccaf4
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 18 additions and 5 deletions

View file

@ -52,8 +52,7 @@ async fn main() -> Result<()> {
.service(cv::page) .service(cv::page)
.service(gaming::page) .service(gaming::page)
.service(memorial::page) .service(memorial::page)
.service(contact::page) .configure(contact::pages)
.service(contact::service_redirection)
.service(portfolio::page) .service(portfolio::page)
.service(setup::page) .service(setup::page)
.service(web3::page) .service(web3::page)

View file

@ -12,7 +12,19 @@ use crate::{
template::{Infos, NavBar}, template::{Infos, NavBar},
}; };
#[get("/contact")] pub fn pages(cfg: &mut web::ServiceConfig) {
// Here define the services used
let routes = |route_path| {
web::scope(route_path)
.service(page)
.service(service_redirection)
};
// Here define the routes aliases
cfg.service(routes("/contact")).service(routes("/c"));
}
#[get("")]
async fn page(req: HttpRequest, config: web::Data<Config>) -> impl Responder { async fn page(req: HttpRequest, config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(build_page( HttpResponse::Ok().body(build_page(
config.get_ref().to_owned(), config.get_ref().to_owned(),
@ -21,11 +33,13 @@ async fn page(req: HttpRequest, config: web::Data<Config>) -> impl Responder {
} }
#[routes] #[routes]
#[get("/contact/{service}")] #[get("/{service}")]
#[get("/contact/{service}/{scope}")] #[get("/{service}/{scope}")]
async fn service_redirection(req: HttpRequest) -> impl Responder { async fn service_redirection(req: HttpRequest) -> impl Responder {
let info = req.match_info(); let info = req.match_info();
let find_redirection = match info.query("service") { let find_redirection = match info.query("service") {
// TODO: XML file with link, so it's not hardcoded here
/* Socials links */ /* Socials links */
"twitter" => Some("https://twitter.com/Mylloon".to_owned()), "twitter" => Some("https://twitter.com/Mylloon".to_owned()),
"mastodon" => Some("https://piaille.fr/@mylloon".to_owned()), "mastodon" => Some("https://piaille.fr/@mylloon".to_owned()),