fix: correctly support !Send Actix APIs in server functions (#3326)

* fix: correctly support `!Send` Actix APIs in server functions

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Greg Johnston
2024-12-07 15:41:32 -05:00
committed by GitHub
parent be3c1811fc
commit 2aa9827a1f

View File

@@ -188,6 +188,20 @@ pub fn server_macro_impl(
})
.collect::<Result<Vec<_>>>()?;
// we need to apply the same sort of Actix SendWrapper workaround here
// that we do for the body of the function provided in the trait (see below)
if cfg!(feature = "actix") {
let block = body.block.to_token_stream();
body.block = quote! {
{
#server_fn_path::actix::SendWrapper::new(async move {
#block
})
.await
}
};
}
let dummy = body.to_dummy_output();
let dummy_name = body.to_dummy_ident();
let args = syn::parse::<ServerFnArgs>(args.into())?;