From ea69f8ce73fd222bdccfb18a3c267f8ba4d04fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurij=20Juki=C4=87?= Date: Mon, 6 Oct 2025 16:48:00 +0200 Subject: [PATCH 1/2] custom error code --- Cargo.lock | 1 - Cargo.toml | 2 +- src/lib.rs | 24 ++++++++++++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe0f162..6d6b573 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1628,7 +1628,6 @@ dependencies = [ [[package]] name = "hyperware_process_lib" version = "2.2.0" -source = "git+https://github.com/hyperware-ai/process_lib?rev=a16d47a#a16d47a2bfae7864e97d70a3914829b4e54a4033" dependencies = [ "alloy", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index f8ea4d7..d255dc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,4 @@ proc-macro2 = "1.0" quote = "1.0" syn = { version = "2.0", features = ["full", "extra-traits"] } -hyperware_process_lib = { git = "https://github.com/hyperware-ai/process_lib", features = ["hyperapp"], rev = "b9f1ead" } +hyperware_process_lib = { path = "/Users/jurij/hyperware_work/process_lib", features = ["hyperapp"] } diff --git a/src/lib.rs b/src/lib.rs index 2970aff..155f50b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1145,8 +1145,18 @@ fn generate_response_handling( }) }); + // Get status code from the current HTTP context + let response_status = hyperware_process_lib::hyperapp::APP_HELPERS.with(|helpers| { + helpers + .borrow() + .current_http_context + .as_ref() + .map(|ctx| ctx.response_status) + .unwrap_or(hyperware_process_lib::http::StatusCode::OK) + }); + hyperware_process_lib::http::server::send_response( - hyperware_process_lib::http::StatusCode::OK, + response_status, headers_opt, response_bytes ); @@ -1403,6 +1413,7 @@ fn generate_http_context_setup() -> proc_macro2::TokenStream { helpers.borrow_mut().current_http_context = Some(hyperware_process_lib::hyperapp::HttpRequestContext { request: http_request, response_headers: std::collections::HashMap::new(), + response_status: hyperware_process_lib::http::StatusCode::OK, }); }); hyperware_process_lib::logging::debug!("HTTP context established"); @@ -1594,8 +1605,17 @@ fn generate_parameterless_handler_dispatch( }) }); + let response_status = hyperware_process_lib::hyperapp::APP_HELPERS.with(|helpers| { + helpers + .borrow() + .current_http_context + .as_ref() + .map(|ctx| ctx.response_status) + .unwrap_or(hyperware_process_lib::http::StatusCode::OK) + }); + hyperware_process_lib::http::server::send_response( - hyperware_process_lib::http::StatusCode::OK, + response_status, headers_opt, response_bytes ); From f9ebb82207af5d29121ca7317b88b2e5e95d7527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurij=20Juki=C4=87?= Date: Mon, 6 Oct 2025 17:12:55 +0200 Subject: [PATCH 2/2] dep fix --- Cargo.lock | 1 + Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 6d6b573..fb166eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1628,6 +1628,7 @@ dependencies = [ [[package]] name = "hyperware_process_lib" version = "2.2.0" +source = "git+https://github.com/hyperware-ai/process_lib?rev=e8b065179ce5d15893a23142416e59c87e0f31f6#e8b065179ce5d15893a23142416e59c87e0f31f6" dependencies = [ "alloy", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index d255dc6..ed674b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,4 @@ proc-macro2 = "1.0" quote = "1.0" syn = { version = "2.0", features = ["full", "extra-traits"] } -hyperware_process_lib = { path = "/Users/jurij/hyperware_work/process_lib", features = ["hyperapp"] } +hyperware_process_lib = { git = "https://github.com/hyperware-ai/process_lib", rev = "e8b065179ce5d15893a23142416e59c87e0f31f6", features = ["hyperapp"] }