blob: ee800c20cf466a59181affdcec2513f3f844847c (
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
|
use rocket::{
get,
http::Header,
response::{self, Responder},
serde::json::{json, Value},
Request,
};
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")]
pub fn r_wellknown_matrix_client() -> Cors<Value> {
Cors(json!({"m.homeserver": {"base_url": "https://matrix.metamuffin.org"}} ))
}
#[get("/.well-known/matrix/server")]
pub fn r_wellknown_matrix_server() -> Cors<Value> {
Cors(json!({"m.server": "matrix.metamuffin.org:443"} ))
}
#[get("/.well-known/security.txt")]
pub fn r_wellknown_security() -> &'static str {
include_str!("../assets/security.txt.asc")
}
#[get("/.well-known/org.flathub.VerifiedApps.txt")]
pub fn r_wellknown_flathub_verified() -> &'static str {
"a29f43db-bd4e-40cb-b121-2899c4d70634\n"
}
|