Skip to content

Commit f37a9fb

Browse files
authored
Merge pull request #1542 from rust-lang/site-template-convert-1
Convert status and bootstrap pages to templates
2 parents 49fcfe9 + 9a41898 commit f37a9fb

File tree

10 files changed

+512
-600
lines changed

10 files changed

+512
-600
lines changed

site/src/server.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,6 @@ async fn handle_fs_path(req: &Request, path: &str) -> Option<http::Response<hype
586586
return Some(not_found());
587587
}
588588

589-
if !Path::new(&fs_path).is_file() {
590-
return None;
591-
}
592-
593589
let etag = ETag::from_str(&*format!(r#""{}""#, *VERSION_UUID)).unwrap();
594590
let mut response = http::Response::builder()
595591
.header_typed(etag.clone())
@@ -602,6 +598,20 @@ async fn handle_fs_path(req: &Request, path: &str) -> Option<http::Response<hype
602598
}
603599
}
604600

601+
let source = match path {
602+
"/bootstrap.html" | "/help.html" | "/status.html" => TEMPLATES
603+
.render(&format!("pages/{}", path.trim_start_matches("/")))
604+
.await
605+
.unwrap()
606+
.into_bytes(),
607+
_ => {
608+
if !Path::new(&fs_path).is_file() {
609+
return None;
610+
}
611+
fs::read(&fs_path).unwrap()
612+
}
613+
};
614+
605615
let p = Path::new(&fs_path);
606616
match p.extension().and_then(|x| x.to_str()) {
607617
Some("html") => response = response.header_typed(ContentType::html()),
@@ -613,11 +623,6 @@ async fn handle_fs_path(req: &Request, path: &str) -> Option<http::Response<hype
613623
_ => (),
614624
}
615625

616-
let source = match path {
617-
"/help.html" => TEMPLATES.render("help.html").await.unwrap().into_bytes(),
618-
_ => fs::read(&fs_path).unwrap(),
619-
};
620-
621626
Some(response.body(hyper::Body::from(source)).unwrap())
622627
}
623628

site/static/bootstrap.html

Lines changed: 0 additions & 304 deletions
This file was deleted.

0 commit comments

Comments
 (0)