Invoker
package revel
func ActionInvoker(c *Controller, _ []Filter) {
methodValue := reflect.ValueOf(c.AppController).MethodByName(c.MethodType.Name)
var methodArgs []reflect.Value
for _, arg := range c.MethodType.Args {
var boundArg reflect.Value
if arg.Type == websocketType {
boundArg = reflect.ValueOf(c.Request.Websocket)
} else {
TRACE.Println("Binding:", arg.Name, "as", arg.Type)
boundArg = Bind(c.Params, arg.Name, arg.Type)
}
methodArgs = append(methodArgs, boundArg)
}
var resultValue reflect.Value
if methodValue.Type().IsVariadic() {
resultValue = methodValue.CallSlice(methodArgs)[0]
} else {
resultValue = methodValue.Call(methodArgs)[0]
}
if resultValue.Kind() == reflect.Interface && !resultValue.IsNil() {
c.Result = resultValue.Interface().(Result)
}
}