diff --git a/client/src/Rocket.toml b/client/src/Rocket.toml new file mode 100644 index 0000000..047520f --- /dev/null +++ b/client/src/Rocket.toml @@ -0,0 +1,4 @@ +[development] +address="localhost" +port=8080 + diff --git a/client/src/main.rs b/client/src/main.rs new file mode 100644 index 0000000..ab6fa09 --- /dev/null +++ b/client/src/main.rs @@ -0,0 +1,55 @@ +// Client based web server app +// Built to serve the purpose of being a basic web client's backend +// For now this the backend for the web client +#![feature(proc_macro_hygiene, decl_macro, plugin)] +//#[macro_use] extern crate serde_derive; +#[macro_use] extern crate rocket; +extern crate rocket_contrib; + +use rocket::response::NamedFile; +use std::io; + +macro_rules! page { + ($type:expr, $item:expr) => { + // TODO: verify against directory traversals + NamedFile::open(format!("staic/{}/{}", $type, $item)) + } +} + +// Pages themselves + +#[get("/")] +fn homepage() -> io::Result { + // Be sure to include some kind of prompt + page!("html", "index") +} +// Handles logging in a user to their home instance +#[get("/login")] +fn login_page() -> io::Result { + page!("html", "login") +} +#[get("/servers")] +fn server_info() -> io::Result { + page!("html", "servers") +} + +// Genearl resources +#[get("/static/css/")] +fn static_css(stylesheet: String) -> io::Result { + page!("css", stylesheet) +} +#[get("/static/js/")] +fn static_js(javascript: String) -> io::Result { + page!("js", javascript) +} + +fn main() { + rocket::ignite() + .mount("/", routes![ + homepage, login_page, server_info + ]) + .mount("/static", routes![ + static_css, static_js + ]) + .launch(); +}