From 3e1a1179f7b85b3c5f6120956257fcb9423e1217 Mon Sep 17 00:00:00 2001 From: fozzie Date: Sat, 19 Jul 2025 16:42:56 -0500 Subject: [PATCH] rename root_path -> app_root --- .env | 2 +- src/handler.rs | 4 ++-- src/main.rs | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.env b/.env index 6575ac8..6589a0b 100644 --- a/.env +++ b/.env @@ -5,4 +5,4 @@ # BIND_PORT=3000 # Locate app at / or e.g. /certcheck -# ROOT_PATH=/ +# APP_ROOT=/ diff --git a/src/handler.rs b/src/handler.rs index a06fcde..ebecbbc 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -33,7 +33,7 @@ pub async fn show_check_form(State(state): State) -> impl IntoResponse key_fingerprint: None, key_description: None, error: None, - post_target: Some(state.root_path), + post_target: Some(state.app_root), }.render().unwrap()) } @@ -98,7 +98,7 @@ fn decode_message_bytes(content: Vec, helper: Helper, url: String, State(sta error: None, key_fingerprint: helper.get_fingerprint(), key_description: helper.get_description(), - post_target: Some(state.root_path), + post_target: Some(state.app_root), }.render().unwrap())), _ => error_response(StatusCode::BAD_REQUEST, "Unable to decode signed doc into UTF-8".to_string()) diff --git a/src/main.rs b/src/main.rs index 09670b4..87d8f7e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use tokio::net::TcpListener; #[derive(Clone)] struct AppState { certs: CertMap, - root_path: String, + app_root: String, } pub type CertMap = HashMap; @@ -43,22 +43,22 @@ async fn main() -> Result<(),Box> { unsafe { env::set_var("BIND_HOST","127.0.0.1"); env::set_var("BIND_PORT","3000"); - env::set_var("ROOT_PATH", "/"); + env::set_var("APP_ROOT", "/"); } // ... then override from .env, ignoring any error (file may not be there) let _ = dotenvy::dotenv_override(); let certs = load_certs_from_fs().await.unwrap(); - let root_path = env::var("ROOT_PATH")?; + let app_root = env::var("APP_ROOT")?; let app_state = AppState{ certs, - root_path: root_path.clone(), + app_root: app_root.clone(), }; let all_routes = Router::new() - .route(&root_path, get(handler::show_check_form)) - .route(&root_path, post(handler::check_canary_result)) + .route(&app_root, get(handler::show_check_form)) + .route(&app_root, post(handler::check_canary_result)) .with_state(app_state); let addr = SocketAddr::new( -- 2.52.0