-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mvc.Register and App.RegisterDependency #2158
Comments
controllerA -> serviceB -> serviceC when i use result :B.C is empty |
The only difference is that |
when i visit http://localhost:9988/test it print : "h say hello..." not "h say hello...4234" why? |
@xieyj-apple Because |
like this? it not work
|
Fixed @xieyj-apple :) |
had new tag or version to fixed it? |
…er().EnableStructDependents() relative to: #2158
Hello @xieyj-apple, I wasn't sure about the stability of this change that's why I didn't publish a new release, until today. Many apps would be broken if we change the default behavior like that. That's why I've added the package main
import (
"fmt"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/mvc"
)
type A struct {
B *B
}
type B struct {
C *C
}
type C struct {
Name string
}
func newC() *C {
return &C{Name: "4234"}
}
type TestController struct {
A *A
}
func (h *TestController) Get(ctx iris.Context) {
fmt.Println("h say hello...", h.A.B.C.Name)
}
func main() {
app := iris.New()
app.Logger().SetLevel("debug")
app.ConfigureContainer().EnableStructDependents()
app.RegisterDependency(newC())
app.RegisterDependency(new(B))
app.RegisterDependency(new(A))
testAPI := app.Party("/test")
m := mvc.New(testAPI)
// OR
// m.EnableStructDependents()
// m.Register(newC())
// m.Register(new(B))
// m.Register(new(A))
m.Handle(new(TestController))
app.Listen(":8080")
} The latest release tag is v12.2.1 |
what diference between mvc.Register and App.RegisterDependency
The text was updated successfully, but these errors were encountered: