Merge a235e0fb32df61edfa9859548c18ca925487cd7f into c224bf82111883dbe354edf9376642f615b7248e

This commit is contained in:
Dmitry Sedykh 2014-07-08 12:14:18 +00:00
commit 4e4e96deba
2 changed files with 9 additions and 8 deletions

15
gin.go
View File

@ -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

View File

@ -69,7 +69,7 @@ func Logger() HandlerFunc {
latency := end.Sub(start)
stdlogger.Printf("[GIN] %v |%s %3d %s| %12v | %s %4s %s\n",
end.Format("2006/01/02 - 15:04:05"),
color, c.Writer.Status(), reset,
color, code, reset,
latency,
requester,
c.Req.Method, c.Req.URL.Path,