Hi, I want to implement dynamic permission system for my forum.
I use Axum.
I thought if I can list all of my routings and every routing assign itself in a specified database row I can create dynamic permission system. That's why I have to list all my routings with their associated routing functions.
Example
async fn pong() -> impl IntoResponse {
StatusCode::OK
}
fn main() {
let router = Router.new().route("/ping", get(pong));
// I need this kind of thing
for routing in router {
assert_eq!((ping, pong), routing);
}
}
I don't see a way in Axum to list routes. And even if there was a way, you would need to add additional information to each route. So it seems you definitely need a separate list or set of routes that you'll have to keep in sync with the routes you add to Axum's Router. Is that what you were wondering about?
You changed a few things that didn’t have to be changed. It is unclear what the problem was.
The changes I can see are:
S renamed to T.
method_router argument in the implementation changed from the associated type to the underlying type. But left as the associated type in the trait definition.
path.to_string() changed to path.to_owned().
All of these changes are no-ops. Am I missing something?
These changes are not important in general. Main situation is I couldn't understand that I have to give another generic to MethodRouter as you said before. Since I'm not very good at traits it was hard for me to understand that you are pointing directly to my problem. That's why I couldn't understand in the first place and thought you understand me wrong. After couple thinking and trying I finally understand your point about defining another trait for MethodRouter then I'm able to implement what I wanted correctly. In the end you solved all of my problems. So right now there is no problem at all.