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