2023-07-16 11:55:06 +00:00
|
|
|
mod config;
|
2023-07-21 16:10:48 +00:00
|
|
|
pub mod gemini;
|
2023-06-18 12:53:25 +00:00
|
|
|
pub mod http;
|
2023-07-09 14:09:00 +00:00
|
|
|
|
2023-07-16 11:55:06 +00:00
|
|
|
pub use config::*;
|
2023-07-31 18:46:54 +00:00
|
|
|
|
|
|
|
use std::borrow;
|
|
|
|
|
|
|
|
fn append_index_to_path<'path, 'index>(
|
|
|
|
path: &'path str,
|
|
|
|
index: &'index str,
|
|
|
|
) -> borrow::Cow<'path, str> {
|
|
|
|
if path.len() == 0 {
|
|
|
|
let mut path = String::with_capacity(1 + index.len());
|
|
|
|
path.push('/');
|
|
|
|
path.push_str(index);
|
|
|
|
return borrow::Cow::Owned(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
if path.ends_with('/') {
|
|
|
|
let mut indexed_path = String::with_capacity(path.len() + index.len());
|
|
|
|
indexed_path.push_str(path.as_ref());
|
|
|
|
indexed_path.push_str(index);
|
|
|
|
return borrow::Cow::Owned(indexed_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
borrow::Cow::Borrowed(path)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn guess_mime(path: &str) -> String {
|
|
|
|
mime_guess::from_path(path)
|
|
|
|
.first_or_octet_stream()
|
|
|
|
.to_string()
|
|
|
|
}
|