♻️ refactor: move file server config into file_server

main
_ 2020-12-20 18:04:19 +00:00
parent e8d94da661
commit 009601e136
2 changed files with 11 additions and 8 deletions

View File

@ -32,13 +32,8 @@ use ptth_server::{
load_toml,
};
#[derive (Default)]
pub struct Config {
pub file_server_root: Option <PathBuf>,
}
struct ServerState <'a> {
config: Config,
config: file_server::Config,
handlebars: handlebars::Handlebars <'a>,
instance_metrics: metrics::Startup,
hidden_path: Option <PathBuf>,
@ -112,7 +107,7 @@ async fn main () -> Result <(), anyhow::Error> {
debug! ("{:?}", instance_metrics);
let state = Arc::new (ServerState {
config: Config {
config: file_server::Config {
file_server_root: config_file.file_server_root,
},
handlebars,

View File

@ -9,7 +9,10 @@ use std::{
collections::HashMap,
convert::{Infallible, TryFrom},
io::SeekFrom,
path::Path,
path::{
Path,
PathBuf,
},
};
use handlebars::Handlebars;
@ -53,6 +56,11 @@ mod emoji {
pub const ERROR: &str = "\u{26a0}\u{fe0f}";
}
#[derive (Default)]
pub struct Config {
pub file_server_root: Option <PathBuf>,
}
#[derive (Serialize)]
struct DirEntryJson {
name: String,