add custom index

This commit is contained in:
JMARyA 2024-09-17 15:34:15 +02:00
parent e4005b38ce
commit 0f35d34bcb
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
7 changed files with 291 additions and 268 deletions

View file

@ -203,6 +203,21 @@ impl Mirror {
None
}
pub fn index_page(&self) -> Option<HttpResponse> {
if let Some(index) = &self.config.index {
return match index.as_str() {
"no" => None,
file => Some(
HttpResponse::Ok()
.content_type("text/html")
.body(std::fs::read_to_string(file).unwrap()),
),
};
}
return None;
}
/// Asynchronously fetches content from the specified URL and saves it to the provided file path.
///
/// This function sends an HTTP GET request to the URL specified by `path`, retrieves the response,