diff options
author | Carson McManus <carson.mcmanus1@gmail.com> | 2024-01-29 00:51:06 +0000 |
---|---|---|
committer | Carson McManus <carson.mcmanus1@gmail.com> | 2024-01-29 00:51:06 +0000 |
commit | 2b029e95570312de19b039c74f55298a439d6ad2 (patch) | |
tree | ebfd1d33374606548b8c477746a97af750f57ef8 /src/listing.rs | |
parent | Bump deps (diff) | |
download | miniserve-2b029e95570312de19b039c74f55298a439d6ad2.tar.gz miniserve-2b029e95570312de19b039c74f55298a439d6ad2.zip |
add `--disable-indexing` cli flag to completely disable directory indexing
Diffstat (limited to '')
-rw-r--r-- | src/listing.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/listing.rs b/src/listing.rs index faa0918..a8668e3 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -376,6 +376,15 @@ pub fn directory_listing( .body(actix_web::body::BodyStream::new(rx)), )) } else { + if conf.disable_indexing { + return Ok(ServiceResponse::new( + req.clone(), + HttpResponse::NotFound() + .content_type(mime::TEXT_PLAIN_UTF_8) + .body("File not found."), + )); + } + Ok(ServiceResponse::new( req.clone(), HttpResponse::Ok().content_type(mime::TEXT_HTML_UTF_8).body( |