Replies: 4 comments 2 replies
-
I'm actually trying to solve the same thing, how can I provide routes in registration or in a central place ex
any idea how to achieve this? |
Beta Was this translation helpful? Give feedback.
-
In our code, we have a function with the signature: func ProvideHandler(pattern string, ctor any) fx.Option
We use reflection to generate a So routing information is then provided at provide time:
Thinking out loud: I wonder if there's an easy API Fx could provide for this category of wrappers. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply, |
Beta Was this translation helpful? Give feedback.
-
@7amou3 you may want to check here: https://github.com/ankorstore/yokai/blob/main/fxhttpserver%2Fregister.go We now support registration of middlewares, handlers and handlers groups, with optional middlewares. This is made to work with Echo, but imo easy to adapt to net/http. Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Hello team, first of all, congrats for Fx, it's amazing.
In your example, you do the following:
and register a route with the following
I'm trying to find a way to have routes, that would NOT carry routing information (so no
Pattern()
method), but instead to define routing information at the moment I register my routes:I tried to play with
Annotate
and making structs that would hold the hanldler constructor function + the pattern, but I can find a way to make this work.If you have any suggestions, it would be greatly appreciated !
Beta Was this translation helpful? Give feedback.
All reactions