You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your project very good skeleton of Actix Web rest API especially your Middleware jwt concept , I have changed to support other database library beside diesel , every thing work fine but I have one issue because of new database library need to working on async example token_utils::verify_token(&token_data, pool).await in file name auth_middleware.rs I hard to call it or how make it works in middleware.
I hope get your help
Thank you
The text was updated successfully, but these errors were encountered:
measproem
changed the title
With middleware function token_utils::verify_token how to support aysnc
How to make middleware support async fucntion call?
Sep 14, 2022
Hello.
I was able to solve this middleware with async functions by doing the following:
Inside the Impl for the AuthenticationMiddleware<S> in the line where I need to make an async call to the DB, I used the executor::block_on() method, and created async block that will have the call of the async function with .await on it.
let my_awaited_return = executor::block_on( async {
my_async_function(&variable).await
});
Depending on your necessity, you might need to move the values to the async block, like this:
let my_awaited_return = executor::block_on( async move {
my_async_function(&moved_variable).await
});
Your project very good skeleton of Actix Web rest API especially your
Middleware
jwt concept , I have changed to support other database library besidediesel
, every thing work fine but I have one issue because of new database library need to working onasync
exampletoken_utils::verify_token(&token_data, pool).await
in file nameauth_middleware.rs
I hard to call it or how make it works in middleware.I hope get your help
Thank you
The text was updated successfully, but these errors were encountered: