too much fucking refactoring.
This commit is contained in:
1 parent
c8ae3d3ff9
commit
920ab5d188
7 files changed
+107
-108
No files matched your search
+12
-11
@@ -1,25 +1,24 @@
|
||||
#![feature(future_join)]
|
||||
|
||||
|
||||
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
use crate::webui::worker::worker_loop;
|
||||
use actix_files;
|
||||
|
||||
use actix_web::{
|
||||
App,
|
||||
dev::ServiceResponse,
|
||||
error,
|
||||
http::{header::ContentType, StatusCode},
|
||||
middleware::{ErrorHandlerResponse, ErrorHandlers, Logger},
|
||||
web, App, FromRequest, HttpRequest, HttpResponse, HttpServer, Responder, Result,
|
||||
FromRequest,
|
||||
http::{header::ContentType, StatusCode}, HttpRequest, HttpResponse, HttpServer, middleware::{ErrorHandlerResponse, ErrorHandlers, Logger}, Responder, Result, web,
|
||||
};
|
||||
use actix_web_lab::respond::Html;
|
||||
use async_channel;
|
||||
use futures::{pin_mut, select, FutureExt};
|
||||
use futures::{FutureExt, pin_mut, select};
|
||||
use minijinja;
|
||||
use minijinja_autoreload::AutoReloader;
|
||||
|
||||
use crate::util::CustomResult;
|
||||
use crate::webui::worker::worker_loop;
|
||||
|
||||
mod views;
|
||||
mod worker;
|
||||
@@ -59,7 +58,7 @@ impl FromRequest for MiniJinjaRenderer {
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io::Result<()> {
|
||||
pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> CustomResult<()> {
|
||||
// The closure is invoked every time the environment is outdated to recreate it.
|
||||
let tmpl_reloader = AutoReloader::new(move |notifier| {
|
||||
let mut env: minijinja::Environment<'static> = minijinja::Environment::new();
|
||||
@@ -95,8 +94,9 @@ pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io
|
||||
.wrap(ErrorHandlers::new().handler(StatusCode::NOT_FOUND, not_found))
|
||||
.wrap(Logger::default())
|
||||
})
|
||||
.workers(2)
|
||||
.bind(("0.0.0.0", port))?;
|
||||
.workers(2)
|
||||
.bind(("0.0.0.0", port))
|
||||
.unwrap();
|
||||
|
||||
let t1 = server.run().fuse();
|
||||
let t2 = worker_loop(r).fuse();
|
||||
@@ -105,7 +105,8 @@ pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io
|
||||
select! {
|
||||
x = t1 => x,
|
||||
y = t2 => y,
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Error handler for a 404 Page not found error.
|
||||
|
||||
Reference in new issue
Block a user