Function leptos_actix::handle_server_fns
source · pub fn handle_server_fns() -> Route
Expand description
An Actix struct@Route that listens for a POST
request with
Leptos server function arguments in the body, runs the server function if found,
and returns the resulting HttpResponse.
This can then be set up at an appropriate route in your application:
use actix_web::*;
fn register_server_functions() {
// call ServerFn::register() for each of the server functions you've defined
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
// make sure you actually register your server functions
register_server_functions();
HttpServer::new(|| {
App::new()
// "/api" should match the prefix, if any, declared when defining server functions
// {tail:.*} passes the remainder of the URL as the server function name
.route("/api/{tail:.*}", leptos_actix::handle_server_fns())
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
§Provided Context Types
This function always provides context values including the following types: