From 176cd813b93f9f21348dfc8127abf2aa670ef7a3 Mon Sep 17 00:00:00 2001 From: minish Date: Fri, 10 Feb 2023 18:57:56 -0500 Subject: [PATCH] add robots.txt --- src/index.rs | 11 +++++++++++ src/main.rs | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/index.rs b/src/index.rs index a34f335..2e2d34c 100644 --- a/src/index.rs +++ b/src/index.rs @@ -8,3 +8,14 @@ pub async fn index(State(engine): State>) -> String { format!("minish's image host, currently hosting {} files", count) } + +// robots.txt that tells web crawlers not to list uploads +const ROBOTS_TXT: &'static str = concat!( + "User-Agent: *\n", + "Disallow: /p/*\n", + "Allow: /\n" +); + +pub async fn robots_txt() -> &'static str { + ROBOTS_TXT +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 3783fa6..2462df6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,7 +45,7 @@ async fn main() { if upload_key.is_empty() { // i would prefer this to be a warning but the default log level hides those - error!("upload key is empty! no key will be required for uploading new files"); + error!("upload key (BRZ_UPLOAD_KEY) is empty! no key will be required for uploading new files"); } // create engine @@ -64,6 +64,7 @@ async fn main() { .route("/new", post(new::new)) .route("/p/:name", get(view::view)) .route("/", get(index::index)) + .route("/robots.txt", get(index::robots_txt)) .with_state(Arc::new(engine)); // start web server