summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs51
1 files changed, 19 insertions, 32 deletions
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 <metamuffin.org>
*/
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<T>(pub T);
-
-#[rocket::async_trait]
-impl<'r, T: Responder<'r, 'static>> Responder<'r, 'static> for Cors<T> {
- 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<Value> {
- Cors(json!({"m.homeserver": {"base_url": "https://matrix.metamuffin.org"}} ))
-}
-
-#[get("/.well-known/matrix/server")]
-fn r_wellknown_matrix_server() -> Cors<Value> {
- Cors(json!({"m.server": "matrix.metamuffin.org:443"} ))
+#[macro_export]
+macro_rules! uri {
+ ($kk:stmt) => {
+ &rocket::uri!($kk).to_string()
+ };
}