fix #210
Showing
1 changed file
with
7 additions
and
5 deletions
| ... | @@ -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" { | ... | ... |
-
Please register or sign in to post a comment