Просмотр исходного кода

Add dev route that fetches build.html file instead of using string in memory.
This is so that the Rust code does not need to re-compile every time the frontend is updated.

Lee Morgan 11 месяцев назад
Родитель
Сommit
23a84c07a6
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      src/routes/other.rs

+ 7 - 0
src/routes/other.rs

@@ -5,6 +5,7 @@ use std::path::PathBuf;
 
 pub fn config(cfg: &mut web::ServiceConfig) {
     cfg.service(landing_page);
+    cfg.service(landing_page_dev);
     cfg.service(svg_logo);
     cfg.service(png_logo);
 }
@@ -17,6 +18,12 @@ async fn landing_page() -> impl Responder {
         .body(html.clone())
 }
 
+#[get("/dev")]
+async fn landing_page_dev() -> Result<NamedFile, Error> {
+    let path: PathBuf = PathBuf::from("src/views/build.html");
+    Ok(NamedFile::open(path)?)
+}
+
 #[get("/logo.svg")]
 async fn svg_logo() -> Result<NamedFile, Error> {
     let path: PathBuf = PathBuf::from("src/views/logo.svg");