From ece589331f6ac4fd311963fe5139b8bf00beda18 Mon Sep 17 00:00:00 2001 From: Will Greenberg Date: Thu, 24 Apr 2025 13:52:11 -0700 Subject: [PATCH] bin: rm unused debug mode functionality With the new svelte-based frontend, there's a better local debug mode using `npm run dev` --- bin/src/server.rs | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/bin/src/server.rs b/bin/src/server.rs index b88b0bc..9065733 100644 --- a/bin/src/server.rs +++ b/bin/src/server.rs @@ -6,7 +6,6 @@ use axum::http::{HeaderValue, StatusCode}; use axum::response::{IntoResponse, Response}; use include_dir::{include_dir, Dir}; use std::sync::Arc; -use tokio::fs::File; use tokio::io::AsyncReadExt; use tokio::sync::mpsc::Sender; use tokio::sync::RwLock; @@ -56,44 +55,12 @@ pub async fn get_qmdl( static STATIC_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/web/build"); pub async fn serve_static( - State(state): State>, + State(_): State>, Path(path): Path, ) -> impl IntoResponse { let path = path.trim_start_matches('/'); let mime_type = mime_guess::from_path(path).first_or_text_plain(); - // if we're in debug mode, return the files from the build directory so we - // don't have to rebuild every time the JS/HTML change - if state.debug_mode { - let mut build_path = std::path::PathBuf::new(); - build_path.push("bin"); - build_path.push("web"); - build_path.push("build"); - for part in path.split("/") { - build_path.push(part); - } - return match File::open(build_path).await { - Ok(mut file) => { - let mut body = String::new(); - file.read_to_string(&mut body) - .await - .expect("failed to read file"); - Response::builder() - .status(StatusCode::OK) - .header( - header::CONTENT_TYPE, - HeaderValue::from_str(mime_type.as_ref()).unwrap(), - ) - .body(Body::from(body)) - .unwrap() - } - Err(_) => Response::builder() - .status(StatusCode::NOT_FOUND) - .body(Body::empty()) - .unwrap(), - }; - } - match STATIC_DIR.get_file(path) { None => Response::builder() .status(StatusCode::NOT_FOUND)