diff --git a/controller.go b/controller.go index 87f331cf..a4ce22fb 100644 --- a/controller.go +++ b/controller.go @@ -36,7 +36,7 @@ type Controller struct { } type ControllerInterface interface { - Init(ct *context.Context, childName string) + Init(ct *context.Context, childName string, app interface{}) Prepare() Get() Post() diff --git a/router.go b/router.go index 12474f6c..3bca9f22 100644 --- a/router.go +++ b/router.go @@ -445,7 +445,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) //call the controller init function method := vc.MethodByName("Init") - in := make([]reflect.Value, 2) + in := make([]reflect.Value, 3) in[0] = reflect.ValueOf(context) in[1] = reflect.ValueOf(runrouter.controllerType.Name()) in[2] = reflect.ValueOf(vc.Interface()) @@ -653,9 +653,10 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) //call the controller init function init := vc.MethodByName("Init") - in := make([]reflect.Value, 2) + in := make([]reflect.Value, 3) in[0] = reflect.ValueOf(context) in[1] = reflect.ValueOf(controllerType.Name()) + in[2] = reflect.ValueOf(vc.Interface()) init.Call(in) //call prepare function in = make([]reflect.Value, 0)