Skip to content

Commit

Permalink
Add a disallow-all response for /robots.txt.
Browse files Browse the repository at this point in the history
  • Loading branch information
denschub committed Mar 25, 2024
1 parent 91f1dcb commit a3e1939
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased development version

This version adds a response to `/robots.txt`, disallowing all robots from interacting with `camo-rs` in any way.

# 1.2.2

This version does not contain any functional changes. It only updates third-party dependencies. Included are two updates that address security issues:
Expand Down
5 changes: 5 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub fn build(settings: Settings) -> Router {
)
.route("/__heartbeat__", get(heartbeat_handler))
.route("/__version__", get(version_handler))
.route("/robots.txt", get(robotstxt_handler))
.fallback(fallback_handler)
.with_state(state)
}
Expand Down Expand Up @@ -81,6 +82,10 @@ async fn version_handler() -> impl IntoResponse {
get_response_with_status_and_text(200, env!("CAMO_RS_VERSION"))
}

async fn robotstxt_handler() -> impl IntoResponse {
get_response_with_status_and_text(200, "User-agent: *\nDisallow: /")
}

async fn fallback_handler() -> impl IntoResponse {
get_response_with_status_and_text(404, "Not found!")
}
Expand Down

0 comments on commit a3e1939

Please sign in to comment.