1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00

Add session.Destroy (before I've added: Increment & Decrement entry helpers as well) | Improve the debug messages for the controllers

Former-commit-id: f5f17b05252a5032ace1e2d0fdd2304fc4004635
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-12-16 23:09:00 +02:00
parent b8cafce6b9
commit 68cc6641d4
7 changed files with 119 additions and 53 deletions

View File

@@ -1,6 +1,9 @@
package di
import "reflect"
import (
"fmt"
"reflect"
)
type (
targetStructField struct {
@@ -13,6 +16,8 @@ type (
//
fields []*targetStructField
Valid bool // is True when contains fields and it's a valid target struct.
trace string // for debug info.
}
)
@@ -56,9 +61,25 @@ func MakeStructInjector(v reflect.Value, hijack Hijacker, goodFunc TypeChecker,
}
s.Valid = len(s.fields) > 0
if s.Valid {
for i, f := range s.fields {
bindmethodTyp := "Static"
if f.Object.BindType == Dynamic {
bindmethodTyp = "Dynamic"
}
elemField := s.elemType.FieldByIndex(f.FieldIndex)
s.trace += fmt.Sprintf("[%d] %s binding: '%s' for field '%s %s'\n", i+1, bindmethodTyp, f.Object.Type.String(), elemField.Name, elemField.Type.String())
}
}
return s
}
func (s *StructInjector) String() string {
return s.trace
}
func (s *StructInjector) Inject(dest interface{}, ctx ...reflect.Value) {
if dest == nil {
return