1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-02-22 20:52:27 +00:00

fix state ownership issue when using the database feature

This commit is contained in:
Dominic 2020-04-16 23:48:54 +02:00
parent 63e6eb9b32
commit 310d7f79d5
Signed by: msrd0
GPG key ID: DCC8C247452E98F9

View file

@ -398,9 +398,14 @@ fn expand(method : Method, attrs : TokenStream, item : TokenStream) -> Result<To
let #repo_ident = <#krate::export::Repo<#conn_ty>>::borrow_from(&#state_ident).clone();
};
block = quote! {
#repo_ident.run::<_, #ret, ()>(move |#conn_ident| {
Ok({#block})
}).await.unwrap()
{
let #res_ident = #repo_ident.run::<_, (#krate::State, #ret), ()>(move |#conn_ident| {
let #res_ident = { #block };
Ok((#state_ident, #res_ident))
}).await.unwrap();
#state_ident = #res_ident.0;
#res_ident.1
}
};
}
if let Some(arg) = args.iter().filter(|arg| (*arg).ty.is_auth_status()).nth(0)