Browse Source

Add HTML POST Form support in Bind

Dmitry Sedykh 11 years ago
parent
commit
a235e0fb32
1 changed files with 8 additions and 7 deletions
  1. 8 7
      gin.go

+ 8 - 7
gin.go

@@ -17,12 +17,13 @@ import (
 )
 
 const (
-	AbortIndex = math.MaxInt8 / 2
-	MIMEJSON   = "application/json"
-	MIMEHTML   = "text/html"
-	MIMEXML    = "application/xml"
-	MIMEXML2   = "text/xml"
-	MIMEPlain  = "text/plain"
+	AbortIndex   = math.MaxInt8 / 2
+	MIMEJSON     = "application/json"
+	MIMEHTML     = "text/html"
+	MIMEXML      = "application/xml"
+	MIMEXML2     = "text/xml"
+	MIMEPlain    = "text/plain"
+	MIMEPOSTForm = "application/x-www-form-urlencoded"
 )
 
 const (
@@ -407,7 +408,7 @@ func (c *Context) Bind(obj interface{}) bool {
 	var b binding.Binding
 	ctype := filterFlags(c.Req.Header.Get("Content-Type"))
 	switch {
-	case c.Req.Method == "GET":
+	case c.Req.Method == "GET" || ctype == MIMEPOSTForm:
 		b = binding.Form
 	case ctype == MIMEJSON:
 		b = binding.JSON