From b816e73bf3525df2ca491735628f49bbcbf69ab5 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sun, 10 Jan 2021 12:01:22 -0500 Subject: [PATCH] add wellknown pages Signed-off-by: Christine Dodrill --- backend/src/main.rs | 13 +++++++------ backend/src/{ => wellknown}/botinfo.txt | 0 backend/src/wellknown/mod.rs | 14 ++++++++++++++ backend/src/wellknown/robots.txt | 2 ++ backend/src/wellknown/security.txt | 2 ++ backend/templates/app.html | 1 + backend/templates/notfound.html | 1 + 7 files changed, 27 insertions(+), 6 deletions(-) rename backend/src/{ => wellknown}/botinfo.txt (100%) create mode 100644 backend/src/wellknown/mod.rs create mode 100644 backend/src/wellknown/robots.txt create mode 100644 backend/src/wellknown/security.txt diff --git a/backend/src/main.rs b/backend/src/main.rs index 4a9ba50..c3b5a41 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -13,10 +13,7 @@ use rocket_prometheus::PrometheusMetrics; use ::mi::{api, frontend, paseto, rocket_trace::*, web::*, MainDatabase, APPLICATION_NAME}; -#[get("/.within/botinfo")] -fn botinfo() -> &'static str { - include_str!("./botinfo.txt") -} +mod wellknown; fn main() -> Result<()> { color_eyre::install()?; @@ -62,11 +59,15 @@ fn main() -> Result<()> { if let Ok(ref mut n) = sdnotify::SdNotify::from_env() { let _ = n .notify_ready() - .map_err(|why| error!("can't signal readiness to systemd: {}", why)); + .map_err(|why| error!("can't signal readiness to systemd: {}", why)) + .unwrap(); } })) .mount("/metrics", prometheus) - .mount("/", routes![botinfo]) + .mount( + "/", + routes![wellknown::botinfo, wellknown::robots, wellknown::security], + ) .mount( "/api", routes![ diff --git a/backend/src/botinfo.txt b/backend/src/wellknown/botinfo.txt similarity index 100% rename from backend/src/botinfo.txt rename to backend/src/wellknown/botinfo.txt diff --git a/backend/src/wellknown/mod.rs b/backend/src/wellknown/mod.rs new file mode 100644 index 0000000..62126c6 --- /dev/null +++ b/backend/src/wellknown/mod.rs @@ -0,0 +1,14 @@ +#[get("/.within/botinfo")] +fn botinfo() -> &'static str { + include_str!("./botinfo.txt") +} + +#[get("/robots.txt")] +fn robots() -> String { + include_str!("./robots.txt").into_string() +} + +#[get("/security.txt")] +fn security() -> String { + include_str!("./security.txt").into_string() +} diff --git a/backend/src/wellknown/robots.txt b/backend/src/wellknown/robots.txt new file mode 100644 index 0000000..1f53798 --- /dev/null +++ b/backend/src/wellknown/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/backend/src/wellknown/security.txt b/backend/src/wellknown/security.txt new file mode 100644 index 0000000..0082e21 --- /dev/null +++ b/backend/src/wellknown/security.txt @@ -0,0 +1,2 @@ +Contact: mailto:me@christine.website +Preferred-Languages: en diff --git a/backend/templates/app.html b/backend/templates/app.html index 7ace735..b48a5b8 100644 --- a/backend/templates/app.html +++ b/backend/templates/app.html @@ -4,6 +4,7 @@ {{ title }} + diff --git a/backend/templates/notfound.html b/backend/templates/notfound.html index eb2e1f1..a547326 100644 --- a/backend/templates/notfound.html +++ b/backend/templates/notfound.html @@ -4,6 +4,7 @@ {{ title }} +