♻️ refactor: move file server runtime state into file_server
parent
31750d30fc
commit
1aff4389bd
|
@ -28,18 +28,12 @@ use ptth_server::{
|
|||
file_server::{
|
||||
self,
|
||||
metrics,
|
||||
State,
|
||||
},
|
||||
load_toml,
|
||||
};
|
||||
|
||||
struct ServerState <'a> {
|
||||
config: file_server::Config,
|
||||
handlebars: handlebars::Handlebars <'a>,
|
||||
instance_metrics: metrics::Startup,
|
||||
hidden_path: Option <PathBuf>,
|
||||
}
|
||||
|
||||
async fn handle_all (req: Request <Body>, state: Arc <ServerState <'static>>)
|
||||
async fn handle_all (req: Request <Body>, state: Arc <State <'static>>)
|
||||
-> Result <Response <Body>, anyhow::Error>
|
||||
{
|
||||
use std::str::FromStr;
|
||||
|
@ -106,7 +100,7 @@ async fn main () -> Result <(), anyhow::Error> {
|
|||
|
||||
debug! ("{:?}", instance_metrics);
|
||||
|
||||
let state = Arc::new (ServerState {
|
||||
let state = Arc::new (State {
|
||||
config: file_server::Config {
|
||||
file_server_root: config_file.file_server_root,
|
||||
},
|
||||
|
|
|
@ -61,6 +61,13 @@ pub struct Config {
|
|||
pub file_server_root: Option <PathBuf>,
|
||||
}
|
||||
|
||||
pub struct State <'a> {
|
||||
pub config: Config,
|
||||
pub handlebars: handlebars::Handlebars <'a>,
|
||||
pub instance_metrics: metrics::Startup,
|
||||
pub hidden_path: Option <PathBuf>,
|
||||
}
|
||||
|
||||
#[derive (Serialize)]
|
||||
struct DirEntryJson {
|
||||
name: String,
|
||||
|
|
Loading…
Reference in New Issue