a62ed10a by astaxie

add supoort AppController

http://play.golang.org/p/MZptHZeYUx
1 parent e79d756d
...@@ -32,6 +32,7 @@ type Controller struct { ...@@ -32,6 +32,7 @@ type Controller struct {
32 gotofunc string 32 gotofunc string
33 CruSession session.SessionStore 33 CruSession session.SessionStore
34 XSRFExpire int 34 XSRFExpire int
35 AppController interface{}
35 } 36 }
36 37
37 type ControllerInterface interface { 38 type ControllerInterface interface {
...@@ -48,13 +49,14 @@ type ControllerInterface interface { ...@@ -48,13 +49,14 @@ type ControllerInterface interface {
48 Render() error 49 Render() error
49 } 50 }
50 51
51 func (c *Controller) Init(ctx *context.Context, childName string) { 52 func (c *Controller) Init(ctx *context.Context, childName string, app interface{}) {
52 c.Data = make(map[interface{}]interface{}) 53 c.Data = make(map[interface{}]interface{})
53 c.Layout = "" 54 c.Layout = ""
54 c.TplNames = "" 55 c.TplNames = ""
55 c.ChildName = childName 56 c.ChildName = childName
56 c.Ctx = ctx 57 c.Ctx = ctx
57 c.TplExt = "tpl" 58 c.TplExt = "tpl"
59 c.AppController = app
58 } 60 }
59 61
60 func (c *Controller) Prepare() { 62 func (c *Controller) Prepare() {
......
...@@ -448,6 +448,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -448,6 +448,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
448 in := make([]reflect.Value, 2) 448 in := make([]reflect.Value, 2)
449 in[0] = reflect.ValueOf(context) 449 in[0] = reflect.ValueOf(context)
450 in[1] = reflect.ValueOf(runrouter.controllerType.Name()) 450 in[1] = reflect.ValueOf(runrouter.controllerType.Name())
451 in[2] = reflect.ValueOf(vc.Interface())
451 method.Call(in) 452 method.Call(in)
452 453
453 //if XSRF is Enable then check cookie where there has any cookie in the request's cookie _csrf 454 //if XSRF is Enable then check cookie where there has any cookie in the request's cookie _csrf
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!