add robots.txt
This commit is contained in:
parent
d0a739386f
commit
176cd813b9
11
src/index.rs
11
src/index.rs
|
@ -8,3 +8,14 @@ pub async fn index(State(engine): State<Arc<crate::engine::Engine>>) -> String {
|
||||||
|
|
||||||
format!("minish's image host, currently hosting {} files", count)
|
format!("minish's image host, currently hosting {} files", count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// robots.txt that tells web crawlers not to list uploads
|
||||||
|
const ROBOTS_TXT: &'static str = concat!(
|
||||||
|
"User-Agent: *\n",
|
||||||
|
"Disallow: /p/*\n",
|
||||||
|
"Allow: /\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
pub async fn robots_txt() -> &'static str {
|
||||||
|
ROBOTS_TXT
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ async fn main() {
|
||||||
|
|
||||||
if upload_key.is_empty() {
|
if upload_key.is_empty() {
|
||||||
// i would prefer this to be a warning but the default log level hides those
|
// i would prefer this to be a warning but the default log level hides those
|
||||||
error!("upload key is empty! no key will be required for uploading new files");
|
error!("upload key (BRZ_UPLOAD_KEY) is empty! no key will be required for uploading new files");
|
||||||
}
|
}
|
||||||
|
|
||||||
// create engine
|
// create engine
|
||||||
|
@ -64,6 +64,7 @@ async fn main() {
|
||||||
.route("/new", post(new::new))
|
.route("/new", post(new::new))
|
||||||
.route("/p/:name", get(view::view))
|
.route("/p/:name", get(view::view))
|
||||||
.route("/", get(index::index))
|
.route("/", get(index::index))
|
||||||
|
.route("/robots.txt", get(index::robots_txt))
|
||||||
.with_state(Arc::new(engine));
|
.with_state(Arc::new(engine));
|
||||||
|
|
||||||
// start web server
|
// start web server
|
||||||
|
|
Loading…
Reference in New Issue