From 3c427d89a51d30274a04a76193eb53aa5d6dcd20 Mon Sep 17 00:00:00 2001 From: ozwaldorf Date: Tue, 15 Oct 2024 16:35:05 -0400 Subject: [PATCH] feat: robots.txt --- src/main.rs | 10 ++++++++-- src/static/robots.txt | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 src/static/robots.txt diff --git a/src/main.rs b/src/main.rs index 3017616..8ea302f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -246,7 +246,7 @@ fn handle_get(req: Request, nonce: usize) -> Result { } let usage = get_usage(&host, false)?; - Ok(Response::from_body(usage).with_content_type(mime::TEXT_PLAIN_UTF_8)) + Ok(Response::new().with_body_text_plain(&usage)) }, // Privacy policy page @@ -265,7 +265,13 @@ fn handle_get(req: Request, nonce: usize) -> Result { } } - Ok(Response::from_body(PRIVACY).with_content_type(mime::TEXT_PLAIN_UTF_8)) + Ok(Response::new().with_body_text_plain(PRIVACY)) + }, + + // Robots + Some("robots.txt") => { + const ROBOTS: &str = include_str!("static/robots.txt"); + Ok(Response::new().with_body_text_plain(ROBOTS)) }, // Favicon diff --git a/src/static/robots.txt b/src/static/robots.txt new file mode 100644 index 0000000..413c501 --- /dev/null +++ b/src/static/robots.txt @@ -0,0 +1,3 @@ +User-agent: * +Disallow: /p/ +Allow: /