Replies: 1 comment
-
This is not strictly an Axum problem, rather general async problem. l What you're trying to do is create a boxed future which can possibly live indefinitely and since you're returning it, it will surely outlive the function. However, you're trying to smuggle the mutable reference to self in there and rustc will not let you. You can't make the reference outlive the function. You can add a bound and just clone the inner service and pass that inside the async block. Be sure to plcall |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
i have question about axum handle async logic in middleware, and already searched there no similar question before. the most similiar is #2213,but it's didn't resolve my problem.
i have a auth middleware, it will get user id and session id from request cookie, and do a match in redis asynchronous ,if match the user, the user information will add into request extension and pass to request handler, in before i user memory synchronous method to do this is ok,now i have to change it into asynchronous,but have some problem please give some advice to help me to make it work.
this code is reference form https://docs.rs/axum/latest/axum/middleware/index.html#towerservice-and-pinboxdyn-future
i found use this would be resolve problem,but still want to know how to resolve on upper code
axum version
0.7.5
Beta Was this translation helpful? Give feedback.
All reactions