Open measproem opened 2 years ago
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
});
This also worked with actix-web version 4
I hope it helps.
Best Regards.
Thank you
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