From dd57e08795efe27b314bcaf1407faca3b205142a Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 12 Feb 2023 21:24:04 +0100 Subject: copy some content from the old page --- src/main.rs | 51 +++++++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 746dfa3..2cee694 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,17 +4,12 @@ Copyright (C) 2023 metamuffin */ pub mod layout; +pub mod pages; +pub mod wellknown; -use rocket::{ - fairing::AdHoc, - fs::FileServer, - get, - http::Header, - response::{self, Responder}, - routes, - serde::json::{json, Value}, - Request, -}; +use pages::*; +use rocket::{catchers, fairing::AdHoc, fs::FileServer, http::Header, routes}; +use wellknown::*; #[tokio::main] async fn main() { @@ -30,33 +25,25 @@ async fn main() { })) .mount( "/", - routes![r_wellknown_matrix_server, r_wellknown_matrix_client,], + routes![ + r_root, + r_about, + r_contact, + r_projects, + r_wellknown_matrix_server, + r_wellknown_matrix_client, + ], ) .mount("/", FileServer::from("modules")) + .register("/", catchers![r_catch]) .launch() .await .unwrap(); } -pub struct Cors(pub T); - -#[rocket::async_trait] -impl<'r, T: Responder<'r, 'static>> Responder<'r, 'static> for Cors { - fn respond_to(self, request: &'r Request<'_>) -> response::Result<'static> { - let mut resp = self.0.respond_to(request); - if let Ok(resp) = &mut resp { - resp.set_header(Header::new("access-control-allow-origin", "*")); - } - resp - } -} - -#[get("/.well-known/matrix/client")] -fn r_wellknown_matrix_client() -> Cors { - Cors(json!({"m.homeserver": {"base_url": "https://matrix.metamuffin.org"}} )) -} - -#[get("/.well-known/matrix/server")] -fn r_wellknown_matrix_server() -> Cors { - Cors(json!({"m.server": "matrix.metamuffin.org:443"} )) +#[macro_export] +macro_rules! uri { + ($kk:stmt) => { + &rocket::uri!($kk).to_string() + }; } -- cgit v1.2.3-70-g09d2