From a235e0fb32df61edfa9859548c18ca925487cd7f Mon Sep 17 00:00:00 2001 From: Dmitry Sedykh Date: Tue, 8 Jul 2014 16:10:27 +0400 Subject: [PATCH] Add HTML POST Form support in Bind --- gin.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gin.go b/gin.go index a06c13a5..55fa8339 100644 --- a/gin.go +++ b/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