// This client code really just serves as the url router for the main website where we describe what the project is about #![feature(proc_macro_hygiene, decl_macro, plugin)] //#[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_derive; #[macro_use] extern crate rocket; extern crate rocket_contrib; use rocket_contrib::serve::StaticFiles; use rocket_contrib::templates::Template; mod website; use website::*; // Purely for backend purposes #[derive(Serialize)] struct PageAttrs { og_title: &'static str, og_type: &'static str, og_desc: &'static str, og_url: &'static str, og_image: &'static str, // General settings favicon: &'static str, // path to the favicon // Branding things brand_url: &'static str, // default is freechat.io - clean url of domain brand_motto: &'static str, brand_quip: &'static str } fn rocket() -> rocket::Rocket { rocket::ignite() .mount("/static", StaticFiles::from("/static")) .mount("/", routes![ homepage, login_page, about_page, server_info, static_css, ]) .attach(Template::fairing()) } fn main() { rocket().launch(); } // Integrating some basic tests just for this module #[cfg(test)] mod test { use super::rocket; use rocket::local::Client; use rocket::http::Status; #[test] fn test_homepage() { // Just make sure that when request the home page we actually get the html back let client = Client::new(rocket()).expect("Valid rocket instance"); let response = client.get("/").dispatch(); assert_eq!(response.status(), Status::Ok); } // Next we test the static resource routes #[test] fn static_css() { let client = Client::new(rocket()).expect("Valid rocket instance"); let response = client.get("/static/css/index.css").dispatch(); assert_eq!(response.status(), Status::Ok); } }