File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ thread_local! {
3737pub struct HttpRequestContext {
3838 pub request : IncomingHttpRequest ,
3939 pub response_headers : HashMap < String , String > ,
40+ pub response_status : http:: StatusCode ,
4041}
4142
4243pub struct AppContext {
@@ -95,6 +96,15 @@ pub fn add_response_header(key: String, value: String) {
9596 } )
9697}
9798
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+
98108pub fn clear_http_request_context ( ) {
99109 APP_HELPERS . with ( |helpers| {
100110 helpers. borrow_mut ( ) . current_http_context = None ;
You can’t perform that action at this time.
0 commit comments