how to resolve dependency from api.Container
- Dominant language
- Go
- Stars
- 25.6k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
### senario
initialize dependencies
1. dependency: config loader
2. dependency: jwt, it will get config information from config loader
use middleware in dependency jwt
problem is How can i resolve dependencies in main() ?
```go
func main() {
app := iris.New()
//jwtSvc := feature.NewJWTService("your-secret-key", "myxtea")
//app.RegisterDependency(func() feature.JWTService {
// return jwtSvc
//})
feature.ProvideConfigLoader(app)
feature.ProvideDatabase(app)
feature.ProvideJWTService(app)
app.ConfigureContainer(func(api *iris.APIContainer) {
// I can see my dependencies injected before
for _, dependency := range api.Container.Dependencies {
fmt.Println(dependency.String())
}
............
```
it looks there is no such Get ore Resolve method for api.Container
any other solutions?
Contributor guide
Assessment
This issue has not been assessed yet.