Stuck at implementation of middleware #1113
-
I am trying to integrate Casbin with Axum to implement a access control middleware. I am using this template to implement the middleware. It seems I am not able to properly define Service, but not sure where I am going wrong Following is the relevant code:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You probably don't want to use Also if you just wanna write a middleware for your app and don't mind using something axum specific then I recommend https://docs.rs/axum/latest/axum/middleware/fn.from_fn.html. See https://docs.rs/axum/latest/axum/middleware/index.html#writing-middleware for the trade offs. |
Beta Was this translation helpful? Give feedback.
You probably don't want to use
Rc<RefCell<S>>
inside a middleware. Why do you think you need that? Usually we recommend cloning the inner service.Also if you just wanna write a middleware for your app and don't mind using something axum specific then I recommend https://docs.rs/axum/latest/axum/middleware/fn.from_fn.html. See https://docs.rs/axum/latest/axum/middleware/index.html#writing-middleware for the trade offs.