Is your feature request related to a problem? Please describe.
When annotating a provider function with fx.As() and fx.ResultTags() at the same time, Fx fails with an error:
2024-06-12T08:18:56.009Z ERROR fxevent/zap.go:59 start failed {"error": "missing dependencies for function \"gitea.example.com/myproject/http/httpfx\".ConfigureServer (/workspaces/myproject/http/httpfx/module.go:20): missing type: http.Handler", "errorVerbose": "missing dependencies for function \"gitea.example.com/myproject/http/httpfx\".ConfigureServer\n\t/workspaces/carbase-backend/http/httpfx/module.go:20:\nmissing type:\n\t- http.Handler (did you mean to Provide it?)"}
Describe the solution you'd like
A clear and concise description of what you want to happen.
It would be great if I could do this:
var Module = fx.Module("chi",
fx.Provide(
fx.Annotate(
NewRouter,
fx.As(new(http.Handler)),
fx.As(new(chi.Router)),
fx.ResultTags(`name:"router"`),
),
),
)
Allowing parts of my application to expect the router while my core bootstrapping logic isn't coupled to Chi in any way and just accepts a router.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
At the moment I just ensure only one http.Handler is available in the DI.
Is this a breaking change?
We do not accept breaking changes to the existing API. Please consider if your proposed solution is backwards compatible. If not, we can help you make it backwards compatible, but this must be considered when we consider new features.
I don't think so.
Additional context
Add any other context or screenshots about the feature request here.
The code above should give a good overview of what I'm trying to achieve, as I want to decouple my HTTP server from whichever router I end up using and just attach the http.Handler to it.
Is your feature request related to a problem? Please describe.
When annotating a provider function with
fx.As()andfx.ResultTags()at the same time, Fx fails with an error:Describe the solution you'd like
A clear and concise description of what you want to happen.
It would be great if I could do this:
Allowing parts of my application to expect the router while my core bootstrapping logic isn't coupled to Chi in any way and just accepts a router.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
At the moment I just ensure only one
http.Handleris available in the DI.Is this a breaking change?
We do not accept breaking changes to the existing API. Please consider if your proposed solution is backwards compatible. If not, we can help you make it backwards compatible, but this must be considered when we consider new features.
I don't think so.
Additional context
Add any other context or screenshots about the feature request here.
The code above should give a good overview of what I'm trying to achieve, as I want to decouple my HTTP server from whichever router I end up using and just attach the
http.Handlerto it.