Add HTML POST Form support in Bind

This commit is contained in:
Dmitry Sedykh 2014-07-08 16:10:27 +04:00
parent 9880758ddb
commit a235e0fb32

3
gin.go
View File

@ -23,6 +23,7 @@ const (
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