passing tests for basic pages and css routes
This commit is contained in:
parent
8bcea3741a
commit
96e6cbb5be
@ -33,10 +33,11 @@ struct PageAttrs {
|
||||
|
||||
fn rocket() -> rocket::Rocket {
|
||||
rocket::ignite()
|
||||
.mount("/static", StaticFiles::from("/static"))
|
||||
.mount("/", routes![
|
||||
homepage, login_page, server_info,
|
||||
static_css,
|
||||
])
|
||||
.mount("/static/css", StaticFiles::from(concat!(env!("CARGO_MANIFEST_DIR"), "/static/css")))
|
||||
.attach(Template::fairing())
|
||||
}
|
||||
|
||||
@ -62,7 +63,7 @@ mod test {
|
||||
#[test]
|
||||
fn static_css() {
|
||||
let client = Client::new(rocket()).expect("Valid rocket instance");
|
||||
let response = client.get("/css/index.css").dispatch();
|
||||
let response = client.get("/static/css/index.css").dispatch();
|
||||
assert_eq!(response.status(), Status::Ok);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// All new servers come with this as a default so that
|
||||
use rocket_contrib::templates::Template;
|
||||
use rocket::response::NamedFile;
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
|
||||
// Purely for backend purposes
|
||||
#[derive(Serialize)]
|
||||
@ -57,3 +57,10 @@ pub fn server_info() -> Template {
|
||||
Template::render("servers", &ctx)
|
||||
}
|
||||
|
||||
#[get("/static/css/<file>")]
|
||||
pub fn static_css(file: String) -> Option<NamedFile> {
|
||||
let mut f = file;
|
||||
f = f.replace("..", "");
|
||||
f = f.replace("%2e", "");
|
||||
NamedFile::open(Path::new("static/css/").join(f)).ok()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user