Files
dioxus/packages/fullstack/src
Ben SullyandEvan Almloff 04fd2487b3 feat(fullstack): add render_handler_with_state (#1687)
* feat(fullstack): add `render_handler_with_state`

When using server functions, the current pattern to access state such as
database connections is to use `register_server_fns_with_handler` on an
Axum router and 'inject' the state into the context provided to the
server function. However, this only affects function calls which go via
the Axum router; SSR renders bypass this, and therefore don't have
access to any state.

This commit adds an alternative `render_handler` which accepts some
additional state. That state is injected into the context in a
similar manner to `register_server_fns_with_handler`. SSR renders can
then proceed to run in the same way as HTTP calls.

* Change state object to 'inject_state' callback

Also add a compiling doctest example.

* remove the explicit for<'a> lifetime

* remove unused assets_path from render_handler_with_context example

---------

Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
2023-12-05 14:10:18 -06:00
..
2023-10-14 12:08:54 -05:00
2023-09-06 17:47:33 -05:00
2023-09-06 17:47:33 -05:00
2023-09-06 17:47:33 -05:00
2023-11-20 08:24:16 -06:00
2023-07-17 16:48:54 -07:00