From 93bb3077b68b88b026abf17c8847060698d0fa86 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Sun, 25 Jun 2023 14:06:56 +0300 Subject: [PATCH] added robots.txt to web server --- p2p-broker/src/server_ws.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/p2p-broker/src/server_ws.rs b/p2p-broker/src/server_ws.rs index 9773d4b..520aae1 100644 --- a/p2p-broker/src/server_ws.rs +++ b/p2p-broker/src/server_ws.rs @@ -197,6 +197,8 @@ fn prepare_urls_from_private_addrs(addrs: &Vec, port: u16) -> Vec, remote: IP, @@ -253,6 +255,14 @@ fn upgrade_ws_or_serve_app( .body(Some(BOOTSTRAP_STRING.get().unwrap().as_bytes().to_vec())) .unwrap(); return Err(res); + } else if uri == "/robots.txt" { + let res = Response::builder() + .status(StatusCode::OK) + .header("Content-Type", "text/plain") + .header("Cache-Control", "max-age=3600, must-revalidate") + .body(Some(ROBOTS.as_bytes().to_vec())) + .unwrap(); + return Err(res); } }