24 lines
559 B
Rust
24 lines
559 B
Rust
use std::path::{Path, PathBuf};
|
|
use rocket::response::NamedFile;
|
|
|
|
#[get("/<path..>", rank = 5)]
|
|
fn all(path: PathBuf) -> Option<NamedFile> {
|
|
NamedFile::open(Path::new("static/").join(path)).ok()
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use rocket;
|
|
use rocket::http::Status;
|
|
use rocket::local::Client;
|
|
|
|
#[test]
|
|
fn all() {
|
|
let client = Client::new(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);
|
|
}
|
|
}
|