mirror of
https://github.com/kataras/iris.git
synced 2026-01-09 13:05:56 +00:00
version 12.1.5
Former-commit-id: cda69f08955cb0d594e98bf26197ee573cbba4b2
This commit is contained in:
@@ -27,8 +27,6 @@ type (
|
||||
// performance reasons.
|
||||
Has bool
|
||||
|
||||
trace string // for debug info.
|
||||
|
||||
lost []*missingInput // Author's note: don't change this to a map.
|
||||
}
|
||||
)
|
||||
@@ -208,7 +206,7 @@ func (s *FuncInjector) Inject(in *[]reflect.Value, ctx ...reflect.Value) {
|
||||
// the caller should be able to in[0] = receiver before injection,
|
||||
// then the `Inject` method should be used instead.
|
||||
func (s *FuncInjector) Call(ctx ...reflect.Value) []reflect.Value {
|
||||
in := make([]reflect.Value, s.Length, s.Length)
|
||||
in := make([]reflect.Value, s.Length)
|
||||
s.Inject(&in, ctx...)
|
||||
return s.fn.Call(in)
|
||||
}
|
||||
|
||||
@@ -146,7 +146,9 @@ func equalTypes(got reflect.Type, expected reflect.Type) bool {
|
||||
// implement this "expected" user handler's input argument.
|
||||
if expected.Kind() == reflect.Interface {
|
||||
// fmt.Printf("expected interface = %s and got to set on the arg is: %s\n", expected.String(), got.String())
|
||||
return got.Implements(expected)
|
||||
// return got.Implements(expected)
|
||||
// return expected.AssignableTo(got)
|
||||
return got.AssignableTo(expected)
|
||||
}
|
||||
|
||||
// if got.String() == "interface {}" {
|
||||
|
||||
@@ -121,7 +121,7 @@ func MakeStructInjector(v reflect.Value, hijack Hijacker, goodFunc TypeChecker,
|
||||
// }
|
||||
// }
|
||||
|
||||
visited := make(map[int]struct{}, 0) // add a visited to not add twice a single value (09-Jul-2019).
|
||||
visited := make(map[int]struct{}) // add a visited to not add twice a single value (09-Jul-2019).
|
||||
fields := lookupFields(s.elemType, true, nil)
|
||||
|
||||
// for idx, val := range values {
|
||||
@@ -286,7 +286,7 @@ func (s *StructInjector) String() (trace string) {
|
||||
}
|
||||
|
||||
// Inject accepts a destination struct and any optional context value(s),
|
||||
// hero and mvc takes only one context value and this is the `context.Contex`.
|
||||
// hero and mvc takes only one context value and this is the `context.Context`.
|
||||
// It applies the bindings to the "dest" struct. It calls the InjectElem.
|
||||
func (s *StructInjector) Inject(dest interface{}, ctx ...reflect.Value) {
|
||||
if dest == nil {
|
||||
@@ -301,6 +301,11 @@ func (s *StructInjector) Inject(dest interface{}, ctx ...reflect.Value) {
|
||||
func (s *StructInjector) InjectElem(destElem reflect.Value, ctx ...reflect.Value) {
|
||||
for _, f := range s.fields {
|
||||
f.Object.Assign(ctx, func(v reflect.Value) {
|
||||
ff := destElem.FieldByIndex(f.FieldIndex)
|
||||
if !v.Type().AssignableTo(ff.Type()) {
|
||||
return
|
||||
}
|
||||
|
||||
destElem.FieldByIndex(f.FieldIndex).Set(v)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ func NewValues() Values {
|
||||
// Clone returns a copy of the current values.
|
||||
func (bv Values) Clone() Values {
|
||||
if n := len(bv); n > 0 {
|
||||
values := make(Values, n, n)
|
||||
values := make(Values, n)
|
||||
copy(values, bv)
|
||||
return values
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ func DispatchFuncResult(ctx context.Context, errorHandler ErrorHandler, values [
|
||||
if statusCode < 400 {
|
||||
statusCode = DefaultErrStatusCode
|
||||
}
|
||||
break // break on first error, error should be in the end but we
|
||||
// break on first error, error should be in the end but we
|
||||
// need to know break the dispatcher if any error.
|
||||
// at the end; we don't want to write anything to the response if error is not nil.
|
||||
|
||||
@@ -505,7 +505,7 @@ func (r View) Dispatch(ctx context.Context) { // r as Response view.
|
||||
}
|
||||
}
|
||||
|
||||
ctx.View(r.Name)
|
||||
_ = ctx.View(r.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ type testCustomResult struct {
|
||||
|
||||
// The only one required function to make that a custom Response dispatcher.
|
||||
func (r testCustomResult) Dispatch(ctx context.Context) {
|
||||
ctx.HTML(r.HTML)
|
||||
_, _ = ctx.HTML(r.HTML)
|
||||
}
|
||||
|
||||
func GetCustomResponse() testCustomResult {
|
||||
@@ -90,7 +90,7 @@ func (e err) Dispatch(ctx context.Context) {
|
||||
// write the status code based on the err's StatusCode.
|
||||
ctx.StatusCode(e.Status)
|
||||
// send to the client the whole object as json
|
||||
ctx.JSON(e)
|
||||
_, _ = ctx.JSON(e)
|
||||
}
|
||||
|
||||
func GetCustomErrorAsDispatcher() err {
|
||||
|
||||
Reference in New Issue
Block a user