797bd982 by astaxie

fix #210

1 parent 4a3d32dc
...@@ -444,18 +444,15 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -444,18 +444,15 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
444 vc := reflect.New(runrouter.controllerType) 444 vc := reflect.New(runrouter.controllerType)
445 445
446 //call the controller init function 446 //call the controller init function
447 init := vc.MethodByName("Init") 447 method := vc.MethodByName("Init")
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 init.Call(in)
452 //call prepare function
453 in = make([]reflect.Value, 0)
454 method := vc.MethodByName("Prepare")
455 method.Call(in) 451 method.Call(in)
456 452
457 //if XSRF is Enable then check cookie where there has any cookie in the request's cookie _csrf 453 //if XSRF is Enable then check cookie where there has any cookie in the request's cookie _csrf
458 if EnableXSRF { 454 if EnableXSRF {
455 in = make([]reflect.Value, 0)
459 method = vc.MethodByName("XsrfToken") 456 method = vc.MethodByName("XsrfToken")
460 method.Call(in) 457 method.Call(in)
461 if r.Method == "POST" || r.Method == "DELETE" || r.Method == "PUT" || 458 if r.Method == "POST" || r.Method == "DELETE" || r.Method == "PUT" ||
...@@ -465,6 +462,11 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -465,6 +462,11 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
465 } 462 }
466 } 463 }
467 464
465 //call prepare function
466 in = make([]reflect.Value, 0)
467 method = vc.MethodByName("Prepare")
468 method.Call(in)
469
468 //if response has written,yes don't run next 470 //if response has written,yes don't run next
469 if !w.started { 471 if !w.started {
470 if r.Method == "GET" { 472 if r.Method == "GET" {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!