Skip to content

Commit

Permalink
Add handler for robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
theodore-s-beers committed Apr 5, 2022
1 parent 3190178 commit 99e7abd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(hello)
.service(robots)
.service(css)
.service(js)
.service(catchall)
Expand All @@ -44,6 +45,12 @@ async fn js() -> actix_web::Result<NamedFile> {
Ok(NamedFile::open(path)?)
}

#[get("/robots.txt")]
async fn robots() -> actix_web::Result<NamedFile> {
let path = Path::new("robots.txt");
Ok(NamedFile::open(path)?)
}

#[get("/{full_path:.+}")]
async fn catchall(path: web::Path<String>) -> impl Responder {
let full_path = path.into_inner();
Expand Down

0 comments on commit 99e7abd

Please sign in to comment.