#45 add support post+_method
Showing
1 changed file
with
6 additions
and
5 deletions
| ... | @@ -227,6 +227,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -227,6 +227,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | requestPath := r.URL.Path | 229 | requestPath := r.URL.Path |
| 230 | r.ParseMultipartForm() | ||
| 230 | 231 | ||
| 231 | //user defined Handler | 232 | //user defined Handler |
| 232 | for pattern, c := range p.userHandlers { | 233 | for pattern, c := range p.userHandlers { |
| ... | @@ -350,18 +351,18 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -350,18 +351,18 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 350 | if r.Method == "GET" { | 351 | if r.Method == "GET" { |
| 351 | method = vc.MethodByName("Get") | 352 | method = vc.MethodByName("Get") |
| 352 | method.Call(in) | 353 | method.Call(in) |
| 353 | } else if r.Method == "POST" { | ||
| 354 | method = vc.MethodByName("Post") | ||
| 355 | method.Call(in) | ||
| 356 | } else if r.Method == "HEAD" { | 354 | } else if r.Method == "HEAD" { |
| 357 | method = vc.MethodByName("Head") | 355 | method = vc.MethodByName("Head") |
| 358 | method.Call(in) | 356 | method.Call(in) |
| 359 | } else if r.Method == "DELETE" { | 357 | } else if r.Method == "DELETE" || (r.Method == "POST" && r.Form.Get("_method") == "delete") { |
| 360 | method = vc.MethodByName("Delete") | 358 | method = vc.MethodByName("Delete") |
| 361 | method.Call(in) | 359 | method.Call(in) |
| 362 | } else if r.Method == "PUT" { | 360 | } else if r.Method == "PUT" || (r.Method == "POST" && r.Form.Get("_method") == "put") { |
| 363 | method = vc.MethodByName("Put") | 361 | method = vc.MethodByName("Put") |
| 364 | method.Call(in) | 362 | method.Call(in) |
| 363 | } else if r.Method == "POST" { | ||
| 364 | method = vc.MethodByName("Post") | ||
| 365 | method.Call(in) | ||
| 365 | } else if r.Method == "PATCH" { | 366 | } else if r.Method == "PATCH" { |
| 366 | method = vc.MethodByName("Patch") | 367 | method = vc.MethodByName("Patch") |
| 367 | method.Call(in) | 368 | method.Call(in) | ... | ... |
-
Please register or sign in to post a comment