mirror of
https://github.com/kataras/iris.git
synced 2025-12-19 19:07:06 +00:00
Update to version 8.5.0 | NEW: MVC Output Result | Read HISTORY.md
Former-commit-id: 6a3579f2500fc715d7dc606478960946dcade61d
This commit is contained in:
@@ -11,52 +11,9 @@ import (
|
||||
// to support more than one input arguments without performance cost compared to previous implementation.
|
||||
// so it's hard-coded written to check the length of input args and their types.
|
||||
func buildMethodCall(a *ast) func(ctx context.Context, f reflect.Value) {
|
||||
// if accepts one or more parameters.
|
||||
if a.dynamic {
|
||||
// if one function input argument then call the function
|
||||
// by "casting" (faster).
|
||||
if l := len(a.paramKeys); l == 1 {
|
||||
paramType := a.paramTypes[0]
|
||||
paramKey := a.paramKeys[0]
|
||||
|
||||
if paramType == paramTypeInt {
|
||||
return func(ctx context.Context, f reflect.Value) {
|
||||
v, _ := ctx.Params().GetInt(paramKey)
|
||||
f.Interface().(func(int))(v)
|
||||
}
|
||||
}
|
||||
|
||||
if paramType == paramTypeLong {
|
||||
return func(ctx context.Context, f reflect.Value) {
|
||||
v, _ := ctx.Params().GetInt64(paramKey)
|
||||
f.Interface().(func(int64))(v)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if paramType == paramTypeBoolean {
|
||||
return func(ctx context.Context, f reflect.Value) {
|
||||
v, _ := ctx.Params().GetBool(paramKey)
|
||||
f.Interface().(func(bool))(v)
|
||||
}
|
||||
}
|
||||
|
||||
// string, path...
|
||||
return func(ctx context.Context, f reflect.Value) {
|
||||
f.Interface().(func(string))(ctx.Params().Get(paramKey))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if func input arguments are more than one then
|
||||
// use the Call method (slower).
|
||||
return func(ctx context.Context, f reflect.Value) {
|
||||
f.Call(a.paramValues(ctx))
|
||||
}
|
||||
}
|
||||
|
||||
// if it's static without any receivers then just call it.
|
||||
// if func input arguments are more than one then
|
||||
// use the Call method (slower).
|
||||
return func(ctx context.Context, f reflect.Value) {
|
||||
f.Interface().(func())()
|
||||
DispatchFuncResult(ctx, f.Call(a.paramValues(ctx)))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user