From 0340e834a6b64cf3903e594fc342d4b40a30a4b8 Mon Sep 17 00:00:00 2001 From: spikecodes <19519553+spikecodes@users.noreply.github.com> Date: Fri, 20 Nov 2020 19:33:38 -0800 Subject: [PATCH] Implement robots.txt --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.rs b/src/main.rs index 1ffa75b..dd451ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,12 @@ async fn style() -> HttpResponse { HttpResponse::Ok().content_type("text/css").body(file) } +#[get("/robots.txt")] +async fn robots() -> HttpResponse { + let file = fs::read_to_string("static/robots.txt").expect("ERROR: Could not read robots.txt"); + HttpResponse::Ok().body(file) +} + #[get("/favicon.ico")] async fn favicon() -> HttpResponse { HttpResponse::Ok().body("") @@ -30,6 +36,7 @@ async fn main() -> std::io::Result<()> { // GENERAL SERVICES .service(style) .service(favicon) + .service(robots) // POST SERVICES .service(post::short) .service(post::page)