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? |
|
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. |
|
Thanks for your reply, |
|
@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. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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
Annotateand 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 !
All reactions