diff --git a/Cargo.lock b/Cargo.lock index 596623d..fb166eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1628,7 +1628,7 @@ dependencies = [ [[package]] name = "hyperware_process_lib" version = "2.2.0" -source = "git+https://github.com/hyperware-ai/process_lib?rev=b9f1ead#b9f1ead63356bfd4b60b337a380fef1be81d81c6" +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 f8ea4d7..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 = { git = "https://github.com/hyperware-ai/process_lib", features = ["hyperapp"], rev = "b9f1ead" } +hyperware_process_lib = { git = "https://github.com/hyperware-ai/process_lib", rev = "e8b065179ce5d15893a23142416e59c87e0f31f6", features = ["hyperapp"] } diff --git a/src/lib.rs b/src/lib.rs index ec70445..e3e29cc 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 );