mirror of
https://github.com/kataras/iris.git
synced 2026-01-09 21:15:56 +00:00
mvc: struct field and method dependency logs on debug level. Read HISTORY.md
- remove Party.GetReporter - Read HISTORY.md
This commit is contained in:
@@ -16,8 +16,9 @@ type binding struct {
|
||||
|
||||
// Input contains the input reference of which a dependency is binded to.
|
||||
type Input struct {
|
||||
Index int // for func inputs
|
||||
StructFieldIndex []int // for struct fields in order to support embedded ones.
|
||||
Index int // for func inputs
|
||||
StructFieldIndex []int // for struct fields in order to support embedded ones.
|
||||
StructFieldName string // the struct field's name.
|
||||
Type reflect.Type
|
||||
|
||||
selfValue reflect.Value // reflect.ValueOf(*Input) cache.
|
||||
@@ -34,6 +35,12 @@ func newInput(typ reflect.Type, index int, structFieldIndex []int) *Input {
|
||||
return in
|
||||
}
|
||||
|
||||
func newStructFieldInput(f reflect.StructField) *Input {
|
||||
input := newInput(f.Type, f.Index[0], f.Index)
|
||||
input.StructFieldName = f.Name
|
||||
return input
|
||||
}
|
||||
|
||||
// String returns the string representation of a binding.
|
||||
func (b *binding) String() string {
|
||||
index := fmt.Sprintf("%d", b.Input.Index)
|
||||
@@ -261,7 +268,7 @@ func getBindingsForStruct(v reflect.Value, dependencies []*Dependency, paramsCou
|
||||
// fmt.Printf("Controller [%s] | NonZero | Field Index: %v | Field Type: %s\n", typ, f.Index, f.Type)
|
||||
bindings = append(bindings, &binding{
|
||||
Dependency: NewDependency(elem.FieldByIndex(f.Index).Interface()),
|
||||
Input: newInput(f.Type, f.Index[0], f.Index),
|
||||
Input: newStructFieldInput(f),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -299,9 +306,10 @@ func getBindingsForStruct(v reflect.Value, dependencies []*Dependency, paramsCou
|
||||
// fmt.Printf(""Controller [%s] | Binding: %s\n", typ, binding.String())
|
||||
|
||||
if len(binding.Input.StructFieldIndex) == 0 {
|
||||
// set correctly the input's field index.
|
||||
structFieldIndex := fields[binding.Input.Index].Index
|
||||
binding.Input.StructFieldIndex = structFieldIndex
|
||||
// set correctly the input's field index and name.
|
||||
f := fields[binding.Input.Index]
|
||||
binding.Input.StructFieldIndex = f.Index
|
||||
binding.Input.StructFieldName = f.Name
|
||||
}
|
||||
|
||||
// fmt.Printf("Controller [%s] | binding Index: %v | binding Type: %s\n", typ, binding.Input.StructFieldIndex, binding.Input.Type)
|
||||
|
||||
Reference in New Issue
Block a user