Fix providing context to server functions (#3174)

* Fix providing context to server functions

* Fix fullstack context test
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-11-06 13:30:41 -05:00
1 parent 3c30a2bffb
commit 416811ba3a
5 files changed
+114 -22

No files matched your search

+8
View File
@@ -262,6 +262,14 @@ mod server_fn_impl {
}
}
#[test]
fn server_context_as_any_map() {
let parts = http::Request::new(()).into_parts().0;
let server_context = DioxusServerContext::new(parts);
server_context.insert_boxed_factory(Box::new(|| Box::new(1234u32)));
assert_eq!(server_context.get::<u32>().unwrap(), 1234u32);
}
std::thread_local! {
pub(crate) static SERVER_CONTEXT: std::cell::RefCell<Box<DioxusServerContext>> = Default::default();
}