summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/VT323-Regular.ttfbin149688 -> 0 bytes
-rw-r--r--src/main.rs34
-rw-r--r--src/types.rs9
3 files changed, 25 insertions, 18 deletions
diff --git a/src/VT323-Regular.ttf b/src/VT323-Regular.ttf
deleted file mode 100644
index 6aec599..0000000
--- a/src/VT323-Regular.ttf
+++ /dev/null
Binary files differ
diff --git a/src/main.rs b/src/main.rs
index 0a17346..e972025 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,7 +3,6 @@ use std::{
net::SocketAddr,
sync::Arc,
};
-use warp::Filter;
mod types;
mod conn;
@@ -12,13 +11,16 @@ use types::*;
use tokio::sync::RwLock;
-const FONT_FILE: &[u8] = include_bytes!("./VT323-Regular.ttf");
+const FONT_FILE: &[u8] = include_bytes!("../assets/VT323-Regular.ttf");
fn main() -> Result<(), Box<dyn Error>> {
let conf = Config {
- cert_path: "./cert.pem".to_owned(),
- pkey_path: "./cert.rsa".to_owned(),
- page_path: "./page.html".to_owned(),
+ cert: "./cert.pem".to_owned(),
+ pkey: "./cert.rsa".to_owned(),
+ room_pg: "./assets/room.html".to_owned(),
+ form_pg: "./assets/form.html".to_owned(),
+ client_code: "./assets/client.js".to_owned(),
+ stylesheet: "./assets/style.css".to_owned(),
socket_addr: ([0,0,0,0],31235).into(),
};
@@ -44,13 +46,14 @@ async fn tokio_main(conf: Config) -> Result<(), Box<dyn Error>> {
}
}));
- let page_route = {
- use warp::*;
- get()
- .and(path("font.ttf"))
- .map(|| FONT_FILE)
- .or(fs::file(conf.page_path.clone()))
- };
+ use warp::*;
+
+ let style = path("s.css").and(fs::file(conf.stylesheet.clone()));
+ let code = path("c.js").and(fs::file(conf.client_code.clone()));
+ let font = path("f.ttf").map(|| FONT_FILE);
+ let listing = path("rlist").map(|| "placeholder'em");
+ let room_form = path("r").map(|| "yeah placeholder mate");
+ let index = path::end().and(fs::file(conf.room_pg.clone()));
let websocket_route = {
let room = room.clone();
@@ -66,12 +69,13 @@ async fn tokio_main(conf: Config) -> Result<(), Box<dyn Error>> {
})
})
};
- let routes = websocket_route.or(page_route);
+ let route = any().and(get().and(index).or(style).or(code).or(font).or(listing)).or(post().and(room_form));
+ let routes = websocket_route.or(route);
let server = warp::serve(routes)
.tls()
- .cert_path(conf.cert_path)
- .key_path(conf.pkey_path)
+ .cert_path(conf.cert)
+ .key_path(conf.pkey)
.run(conf.socket_addr);
println!("Serving on {}", conf.socket_addr);
server.await;
diff --git a/src/types.rs b/src/types.rs
index 86f1e32..fb9f7ae 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -14,9 +14,12 @@ use crate::minesweeper;
#[derive(Debug, Clone)]
pub struct Config {
- pub cert_path: String,
- pub pkey_path: String,
- pub page_path: String,
+ pub cert: String,
+ pub pkey: String,
+ pub room_pg: String,
+ pub form_pg: String,
+ pub client_code: String,
+ pub stylesheet: String,
pub socket_addr: SocketAddr,
}