goanna/handler.go
func (handler ControllerHandler) getResponse(r *http.Request) Response {
	controller := handler.factory()
	controller.SetRequest(r)
	controller.Init()
	rController := reflect.ValueOf(controller)
	method := rController.MethodByName(handler.methodName)

	// get args from gorilla mux
	var args []reflect.Value
	for _, val := range mux.Vars(r) {
		args = append(args, reflect.ValueOf(val))
	}

	// make sure number of args matches the controller method
	expected := len(args)
	actual := method.Type().NumIn()
	if expected != actual {
		panic(fmt.Sprintf("Method '%s' has %d args, expected %d", handler.methodName, actual, expected))
	}

	out := method.Call(args)
	if out[0].IsNil() {
		panic("Response from controller was nil")
	}

	resp := out[0].Interface().(Response)
	if resp == nil {
		panic("Response from controller was not Response interface")
	}

	controller.Session().WriteToResponse(resp)
	return resp
}
func (handler ControllerHandler) getResponse(r *http.Request) Response {
	controller := handler.factory()
	controller.SetRequest(r)
	controller.Init()
	rController := reflect.ValueOf(controller)
	method := rController.MethodByName(handler.methodName)

	// get args from gorilla mux
	var args []reflect.Value
	for _, val := range mux.Vars(r) {
		args = append(args, reflect.ValueOf(val))
	}

	// make sure number of args matches the controller method
	expected := len(args)
	actual := method.Type().NumIn()
	if expected != actual {
		panic(fmt.Sprintf("Method '%s' has %d args, expected %d", handler.methodName, actual, expected))
	}

	out := method.Call(args)
	if out[0].IsNil() {
		panic("Response from controller was nil")
	}

	resp := out[0].Interface().(Response)
	if resp == nil {
		panic("Response from controller was not Response interface")
	}

	controller.Session().WriteToResponse(resp)
	return resp
}
// getResponse executes the specified controller's method using reflection
// and returns the response object