Implement robots.txt

This commit is contained in:
spikecodes 2020-11-20 19:33:38 -08:00
parent 4dbb5367e7
commit 0340e834a6

View File

@ -15,6 +15,12 @@ async fn style() -> HttpResponse {
HttpResponse::Ok().content_type("text/css").body(file) 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")] #[get("/favicon.ico")]
async fn favicon() -> HttpResponse { async fn favicon() -> HttpResponse {
HttpResponse::Ok().body("") HttpResponse::Ok().body("")
@ -30,6 +36,7 @@ async fn main() -> std::io::Result<()> {
// GENERAL SERVICES // GENERAL SERVICES
.service(style) .service(style)
.service(favicon) .service(favicon)
.service(robots)
// POST SERVICES // POST SERVICES
.service(post::short) .service(post::short)
.service(post::page) .service(post::page)