Merge pull request #867 from WithGJR/develop
fix router bug: when the request is PUT or DELETE, router can't find the...
This commit is contained in:
		
						commit
						24489df63d
					
				
							
								
								
									
										12
									
								
								router.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								router.go
									
									
									
									
									
								
							| @ -648,7 +648,17 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if !findrouter { | 	if !findrouter { | ||||||
| 		if t, ok := p.routers[r.Method]; ok { | 		http_method := r.Method | ||||||
|  | 
 | ||||||
|  | 		if http_method == "POST" && context.Input.Query("_method") == "PUT" { | ||||||
|  | 			http_method = "PUT" | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		if http_method == "POST" && context.Input.Query("_method") == "DELETE" { | ||||||
|  | 			http_method = "DELETE" | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		if t, ok := p.routers[http_method]; ok { | ||||||
| 			runObject, p := t.Match(urlPath) | 			runObject, p := t.Match(urlPath) | ||||||
| 			if r, ok := runObject.(*controllerInfo); ok { | 			if r, ok := runObject.(*controllerInfo); ok { | ||||||
| 				routerInfo = r | 				routerInfo = r | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user