1
0
mirror of https://github.com/kataras/iris.git synced 2026-03-10 02:16:10 +00:00

Add status code 103 Early Hints. Add the ability to customize and change the order of controller's fields and their registered valid dependencies relative to: #1343

Former-commit-id: 5bd9e02e5fafca135d17cad87f4a9aec526b333b
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-08-26 16:43:02 +03:00
parent 9d09e8637b
commit bd5f96086b
10 changed files with 116 additions and 33 deletions

View File

@@ -33,6 +33,7 @@ func Struct(s interface{}, values ...reflect.Value) *StructInjector {
ValueOf(s),
DefaultHijacker,
DefaultTypeChecker,
SortByNumMethods,
Values(values).CloneWithFieldsOf(s)...,
)
}
@@ -64,6 +65,7 @@ type D struct {
hijacker Hijacker
goodFunc TypeChecker
sorter Sorter
}
// New creates and returns a new Dependency Injection container.
@@ -85,13 +87,20 @@ func (d *D) GoodFunc(fn TypeChecker) *D {
return d
}
// Sort sets the fields and valid bindable values sorter for struct injection.
func (d *D) Sort(with Sorter) *D {
d.sorter = with
return d
}
// Clone returns a new Dependency Injection container, it adopts the
// parent's (current "D") hijacker, good func type checker and all dependencies values.
// parent's (current "D") hijacker, good func type checker, sorter and all dependencies values.
func (d *D) Clone() *D {
return &D{
Values: d.Values.Clone(),
hijacker: d.hijacker,
goodFunc: d.goodFunc,
sorter: d.sorter,
}
}
@@ -108,6 +117,7 @@ func (d *D) Struct(s interface{}) *StructInjector {
ValueOf(s),
d.hijacker,
d.goodFunc,
d.sorter,
d.Values.CloneWithFieldsOf(s)...,
)
}