mirror of
				https://github.com/gin-gonic/gin.git
				synced 2025-11-04 09:12:12 +08:00 
			
		
		
		
	Add HTML POST Form support in Bind
This commit is contained in:
		
							parent
							
								
									9880758ddb
								
							
						
					
					
						commit
						a235e0fb32
					
				
							
								
								
									
										3
									
								
								gin.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								gin.go
									
									
									
									
									
								
							@ -23,6 +23,7 @@ const (
 | 
				
			|||||||
	MIMEXML      = "application/xml"
 | 
						MIMEXML      = "application/xml"
 | 
				
			||||||
	MIMEXML2     = "text/xml"
 | 
						MIMEXML2     = "text/xml"
 | 
				
			||||||
	MIMEPlain    = "text/plain"
 | 
						MIMEPlain    = "text/plain"
 | 
				
			||||||
 | 
						MIMEPOSTForm = "application/x-www-form-urlencoded"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@ -407,7 +408,7 @@ func (c *Context) Bind(obj interface{}) bool {
 | 
				
			|||||||
	var b binding.Binding
 | 
						var b binding.Binding
 | 
				
			||||||
	ctype := filterFlags(c.Req.Header.Get("Content-Type"))
 | 
						ctype := filterFlags(c.Req.Header.Get("Content-Type"))
 | 
				
			||||||
	switch {
 | 
						switch {
 | 
				
			||||||
	case c.Req.Method == "GET":
 | 
						case c.Req.Method == "GET" || ctype == MIMEPOSTForm:
 | 
				
			||||||
		b = binding.Form
 | 
							b = binding.Form
 | 
				
			||||||
	case ctype == MIMEJSON:
 | 
						case ctype == MIMEJSON:
 | 
				
			||||||
		b = binding.JSON
 | 
							b = binding.JSON
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user