// Starts the server in its own thread.
Starts the server in its own thread.
Starts the server in its own thread .
pub fn start_server(config: &config::Config) -> config::VhostApi {
    let config = config.clone();
    let app_data = Shared::adopt(AppData {
        root_path: config.root_path.clone(),
        csp: config.csp.clone(),
        zips: HashMap::new(),
    });
    let vhost_api = VhostApi::new(app_data.clone());
    thread::Builder::new()
        .name("virtual host server".into())
        .spawn(move || {
            let sys = actix_rt::System::new("vhost-server");
            info!(
                "Starting vhost server from {} on localhost:{}",
                config.root_path, config.port
            );
            let tls_config = match get_tls_server_config(&config) {
                Ok(config) => config,
                Err(_) => return,
            };
            HttpServer::new(move || {
                App::new()
                    .data(app_data.clone())
                    .wrap(Logger::new("\"%r\" %{Host}i %s %b %D")) // Custom log to display the vhost
                    .wrap(Cors::new().send_wildcard().finish())
                    .route("/{filename:.*}", web::get().to(vhost))
            })
            .disable_signals() // For now, since that's causing us issues with Ctrl-C
            .bind_rustls(format!("localhost:{}", config.port), tls_config)
            .unwrap()
            .run();
            let _ = sys.run();
        })
        .expect("Failed to start vhost server thread");
    vhost_api
}
pub fn start_server ( config : & config :: Config ) -> config :: VhostApi { let config = config . clone ( ) ; let app_data = Shared :: adopt ( AppData { root_path : config . root_path . clone ( ) , csp : config . csp . clone ( ) , zips : HashMap :: new ( ) , } ) ; let vhost_api = VhostApi :: new ( app_data . clone ( ) ) ; thread :: Builder :: new ( ) . name ( " " . into ( ) ) . spawn ( move | | { let sys = actix_rt :: System :: new ( " " ) ; info ! ( " " config root_path config port ) ; let tls_config = match get_tls_server_config ( & config ) { Ok ( config ) => config , Err ( _ ) => return , } ; HttpServer :: new ( move | | { App :: new ( ) . data ( app_data . clone ( ) ) . wrap ( Logger :: new ( " \" \" " ) ) // Custom log to display the vhost . wrap ( Cors :: new ( ) . send_wildcard ( ) . finish ( ) ) . route ( " " , web :: get ( ) . to ( vhost ) ) } ) . disable_signals ( ) // For now, since that's causing us issues with Ctrl-C . bind_rustls ( format ! ( " " config port ) , tls_config ) . unwrap ( ) . run ( ) ; let _ = sys . run ( ) ; } ) . expect ( " " ) ; vhost_api }
Starts the server in its own thread.
Starts the server in its own thread .
config
&config::Config