use rocket::get; use rocket::response::NamedFile; use std::path::{Path, PathBuf}; #[get("/", rank = 5)] pub(crate) fn all(path: PathBuf) -> Option { NamedFile::open( Path::new(env!("CARGO_MANIFEST_DIR")) .join("static") .join(path), ) .ok() } #[cfg(test)] mod tests { use rocket::http::Status; use rocket::local::Client; #[test] fn all() { let client = Client::new(crate::rocket(Some("test"))).unwrap(); // Try to get the main JavaScript file let res = client.get("/js/pinboard.js").dispatch(); assert_eq!(res.status(), Status::Ok); } }