summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-05-18 17:43:12 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-05-18 18:05:35 +0200
commitc1b8a4ee05ead72fa1db40a3c22faa2acf249a81 (patch)
tree5a96142f9c7127e28c3534e66e4fdde27c5fb356
parentf5688f1ae36a646134a21b138c48a1f508c611ce (diff)
Fix spawning
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/gui.rs13
-rw-r--r--src/server.rs14
2 files changed, 22 insertions, 5 deletions
diff --git a/src/gui.rs b/src/gui.rs
index eb145f4..574d6de 100644
--- a/src/gui.rs
+++ b/src/gui.rs
@@ -1,5 +1,9 @@
+use std::fmt::Debug;
+
use anyhow::Error;
use anyhow::Result;
+use web_view::WVResult;
+use web_view::WebView;
use crate::app::App;
use crate::cli::*;
@@ -27,7 +31,7 @@ pub fn run_gui(config: Configuration, adr: String) -> Result<()> {
}
};
- let webview_content = web_view::Content::Url(adr.clone());
+ let webview_content = web_view::Content::Url(format!("http://{}", adr));
web_view::builder()
.title("My Project")
@@ -35,10 +39,15 @@ pub fn run_gui(config: Configuration, adr: String) -> Result<()> {
.resizable(true)
.debug(true)
.user_data(())
- .invoke_handler(|_webview, _arg| Ok(()))
+ .invoke_handler(invoke_handler)
.build()
.map_err(Error::from)?
.run()
.map_err(Error::from)
}
+fn invoke_handler<T: Debug>(webview: &mut WebView<T>, s: &str) -> WVResult {
+ debug!("invoke-handler: {:?}, {:?}", webview, s);
+ Ok(())
+}
+
diff --git a/src/server.rs b/src/server.rs
index 65956e8..bf97b87 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -1,3 +1,5 @@
+use std::path::PathBuf;
+
use actix_web::{web, HttpResponse, Responder};
use anyhow::Error;
use anyhow::Result;
@@ -15,7 +17,7 @@ pub fn do_start(cli: &CLI) -> bool {
}
pub fn is_running(server_lock: &Pidlock) -> bool {
- *server_lock.state() == PidlockState::Acquired
+ PathBuf::from("/tmp/distrox_server.pid").exists()
}
@@ -26,7 +28,7 @@ pub async fn run_server(mut server_lock: Pidlock, adr: String) -> Result<()> {
info!("Got PID lock for server");
actix_web::HttpServer::new(|| {
actix_web::App::new()
- .service(actix_web::web::resource("/{name}/{id}/index.html").to(index))
+ .route("*", actix_web::web::get().to(index))
})
.bind(adr.clone())
.expect(&format!("Could not bind to address {}", adr))
@@ -39,6 +41,12 @@ pub async fn run_server(mut server_lock: Pidlock, adr: String) -> Result<()> {
}
async fn index() -> impl Responder {
- HttpResponse::Ok()
+ debug!("serve index");
+ format!("{pre}{style}{index}{post}",
+ pre = include_str!("../assets/index_pre.html"),
+ style = include_str!("../assets/style.css"),
+ index = include_str!("../assets/index.html"),
+ post = include_str!("../assets/index_post.html"),
+ )
}