Function leptos_actix::extract

source ·
pub async fn extract<T>() -> Result<T, ServerFnError>
where T: FromRequest, <T as FromRequest>::Error: Display,
Expand description

A helper to make it easier to use Actix extractors in server functions.

It is generic over some type T that implements FromRequest and can therefore be used in an extractor. The compiler can often infer this type.

Any error that occurs during extraction is converted to a ServerFnError.

// MyQuery is some type that implements `Deserialize + Serialize`
#[server]
pub async fn query_extract() -> Result<MyQuery, ServerFnError> {
    use actix_web::web::Query;
    use leptos_actix::*;

    let Query(data) = extract().await?;

    // do something with the data

    Ok(data)
}