Using the Handler trait as part of another trait | How to colocate config next to handler fn #2794
Unanswered
enricoschaaf
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hi 👋🏽
I am new to Axum and Rust and I am wondering how you would handle the following.
I would like to colocate some information for a certain handler with the handler fn itself. Like the path, rate limiting settings, etc. For this I imagined I could do it like this
but since Handler is a trait not a fn I am not sure how to add it to my trait. I tried to use a function that returns the trait but I also did not get this to work bc of this error
the trait "axum::handler::Handler" cannot be made into an object
Looking forward to hear how I could fix my approach or if there are any better approaches on how to handle this. Btw for registering the route I would have made a light wrapper around router that has a method that accepts my trait and correctly handles all the info that the trait provided.
Thanks 🙏🏽
axum version
Latest
Beta Was this translation helpful? Give feedback.
All reactions