Skip to content

Use a trait function as a handler #3313

Answered by DxUr
DxUr asked this question in Q&A
Apr 19, 2025 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

I have fixed the problem by now, the idea is to declare the routes on a common crate between the front end and backend then using a macro the traint which contains the routes get compiled to fetch requests on frontend and a trait that you should implement on the backend i want to automatically generate a function on the trait make_router so i dont need to bind the routes by hand i fix it passing the struct that will implement the trait to the macro so the macro can generate an impl block for it, basically trait items do not implement the Handler trait so i cant use them directly.
After a week of developing I found it useless since i need to set some middelwares.

this is an example on how …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DxUr
Comment options

Answer selected by DxUr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants