Function leptos_actix::handle_server_fns_with_context
source · pub fn handle_server_fns_with_context(
additional_context: impl Fn() + 'static + Clone + Send
) -> Route
Expand description
An Actix struct@Route that listens for GET
or POST
requests with
Leptos server function arguments in the URL (GET
) or body (POST
),
runs the server function if found, and returns the resulting HttpResponse.
This can then be set up at an appropriate route in your application:
This version allows you to pass in a closure that adds additional route data to the context, allowing you to pass in info about the route or user from Actix, or other info.
NOTE: If your server functions expect a context, make sure to provide it both in
handle_server_fns_with_context
and in LeptosRoutes::leptos_routes_with_context
(or whatever
rendering method you are using). During SSR, server functions are called by the rendering
method, while subsequent calls from the client are handled by the server function handler.
The same context needs to be provided to both handlers.
§Provided Context Types
This function always provides context values including the following types: