nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 64 lines 2.9 kB view raw
1From a09babb0cd9dd532ad2de920a2a35aa03d740dc6 Mon Sep 17 00:00:00 2001 2From: Herwig Hochleitner <herwig@bendlas.net> 3Date: Thu, 8 Aug 2024 00:29:14 +0200 4Subject: [PATCH] parameterize frontend location 5 6--- 7 server/src/infra/tcp_server.rs | 14 +++++++------- 8 1 file changed, 7 insertions(+), 7 deletions(-) 9 10diff --git a/server/src/infra/tcp_server.rs b/server/src/infra/tcp_server.rs 11index fa5f11f..16e64c5 100644 12--- a/server/src/infra/tcp_server.rs 13+++ b/server/src/infra/tcp_server.rs 14@@ -25,7 +25,7 @@ use std::sync::RwLock; 15 use tracing::info; 16 17 async fn index<Backend>(data: web::Data<AppState<Backend>>) -> actix_web::Result<impl Responder> { 18- let mut file = std::fs::read_to_string(r"./app/index.html")?; 19+ let mut file = std::fs::read_to_string(r"@frontend@/index.html")?; 20 21 if data.server_url.path() != "/" { 22 file = file.replace( 23@@ -80,7 +80,7 @@ pub(crate) fn error_to_http_response(error: TcpError) -> HttpResponse { 24 async fn main_js_handler<Backend>( 25 data: web::Data<AppState<Backend>>, 26 ) -> actix_web::Result<impl Responder> { 27- let mut file = std::fs::read_to_string(r"./app/static/main.js")?; 28+ let mut file = std::fs::read_to_string(r"@frontend@/static/main.js")?; 29 30 if data.server_url.path() != "/" { 31 file = file.replace("/pkg/", format!("{}/pkg/", data.server_url.path()).as_str()); 32@@ -92,12 +92,12 @@ async fn main_js_handler<Backend>( 33 } 34 35 async fn wasm_handler() -> actix_web::Result<impl Responder> { 36- Ok(actix_files::NamedFile::open_async("./app/pkg/lldap_app_bg.wasm").await?) 37+ Ok(actix_files::NamedFile::open_async("@frontend@/pkg/lldap_app_bg.wasm").await?) 38 } 39 40 async fn wasm_handler_compressed() -> actix_web::Result<impl Responder> { 41 Ok( 42- actix_files::NamedFile::open_async("./app/pkg/lldap_app_bg.wasm.gz") 43+ actix_files::NamedFile::open_async("@frontend@/pkg/lldap_app_bg.wasm.gz") 44 .await? 45 .customize() 46 .insert_header(header::ContentEncoding::Gzip) 47@@ -143,11 +143,11 @@ fn http_config<Backend>( 48 .service(web::resource("/pkg/lldap_app_bg.wasm").route(web::route().to(wasm_handler))) 49 .service(web::resource("/static/main.js").route(web::route().to(main_js_handler::<Backend>))) 50 // Serve the /pkg path with the compiled WASM app. 51- .service(Files::new("/pkg", "./app/pkg")) 52+ .service(Files::new("/pkg", "@frontend@/pkg")) 53 // Serve static files 54- .service(Files::new("/static", "./app/static")) 55+ .service(Files::new("/static", "@frontend@/static")) 56 // Serve static fonts 57- .service(Files::new("/static/fonts", "./app/static/fonts")) 58+ .service(Files::new("/static/fonts", "@frontend@/static/fonts")) 59 // Default to serve index.html for unknown routes, to support routing. 60 .default_service(web::route().guard(guard::Get()).to(index::<Backend>)); 61 } 62-- 632.45.2 64