summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 72bd8911fbc329ebe9fa930dbd5a16634f54a541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
    This file is part of metamuffins website (https://codeberg.org/metamuffin/website)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2023 metamuffin <metamuffin.org>
*/
pub mod blog;
pub mod error;
pub mod layout;
pub mod pages;
pub mod source;
pub mod wellknown;

use blog::*;
use error::*;
use pages::*;
use rocket::{catchers, fairing::AdHoc, http::Header, routes};
use source::*;
use wellknown::*;

#[tokio::main]
async fn main() {
    env_logger::init_from_env("LOG");
    let _ = rocket::build()
        .attach(AdHoc::on_response("set server header", |_req, res| {
            res.set_header(Header::new("server", "blub"));
            Box::pin(async {})
        }))
        .manage(prepare_source())
        .mount(
            "/",
            routes![
                r_root,
                r_about,
                r_contact,
                r_projects,
                r_pgp_key,
                r_source,
                r_blog,
                r_stuff,
                r_favicon,
                r_blog_index,
                r_blog_article,
                r_blog_atom,
                r_style,
                r_toggle_css,
                r_wellknown_security,
                r_wellknown_matrix_server,
                r_wellknown_matrix_client,
            ],
        )
        .register("/", catchers![r_catch])
        .launch()
        .await
        .unwrap();
}

#[macro_export]
macro_rules! uri {
    ($kk:stmt) => {
        &rocket::uri!($kk).to_string()
    };
}