We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents d67b65e + e8b0651 commit b7f9f03Copy full SHA for b7f9f03
1 file changed
src/hyperapp.rs
@@ -37,6 +37,7 @@ thread_local! {
37
pub struct HttpRequestContext {
38
pub request: IncomingHttpRequest,
39
pub response_headers: HashMap<String, String>,
40
+ pub response_status: http::StatusCode,
41
}
42
43
pub struct AppContext {
@@ -95,6 +96,15 @@ pub fn add_response_header(key: String, value: String) {
95
96
})
97
98
99
+// Set the HTTP response status code
100
+pub fn set_response_status(status: http::StatusCode) {
101
+ APP_HELPERS.with(|helpers| {
102
+ if let Some(ctx) = &mut helpers.borrow_mut().current_http_context {
103
+ ctx.response_status = status;
104
+ }
105
+ })
106
+}
107
+
108
pub fn clear_http_request_context() {
109
APP_HELPERS.with(|helpers| {
110
helpers.borrow_mut().current_http_context = None;
0 commit comments