diff options
author | Carson McManus <carson.mcmanus1@gmail.com> | 2024-01-30 14:45:56 +0000 |
---|---|---|
committer | Carson McManus <carson.mcmanus1@gmail.com> | 2024-01-30 14:45:56 +0000 |
commit | cf46ce687c84fc831b1c7edd50fbc68619792275 (patch) | |
tree | afaa4c69bd58cf40db9b4b01baff76caff0af3c7 /src | |
parent | Revert "completely disable the listing renderer when indexing is disabled" (diff) | |
download | miniserve-cf46ce687c84fc831b1c7edd50fbc68619792275.tar.gz miniserve-cf46ce687c84fc831b1c7edd50fbc68619792275.zip |
move check for disable_indexing
Diffstat (limited to '')
-rw-r--r-- | src/listing.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/listing.rs b/src/listing.rs index a8668e3..c837576 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -161,6 +161,14 @@ pub fn directory_listing( let current_user: Option<&CurrentUser> = extensions.get::<CurrentUser>(); let conf = req.app_data::<crate::MiniserveConfig>().unwrap(); + if conf.disable_indexing { + return Ok(ServiceResponse::new( + req.clone(), + HttpResponse::NotFound() + .content_type(mime::TEXT_PLAIN_UTF_8) + .body("File not found."), + )); + } let serve_path = req.path(); let base = Path::new(serve_path); @@ -376,15 +384,6 @@ 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( |