mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 20:22:20 +08:00
Merge a235e0fb32df61edfa9859548c18ca925487cd7f into c224bf82111883dbe354edf9376642f615b7248e
This commit is contained in:
commit
4e4e96deba
15
gin.go
15
gin.go
@ -17,12 +17,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AbortIndex = math.MaxInt8 / 2
|
AbortIndex = math.MaxInt8 / 2
|
||||||
MIMEJSON = "application/json"
|
MIMEJSON = "application/json"
|
||||||
MIMEHTML = "text/html"
|
MIMEHTML = "text/html"
|
||||||
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
|
||||||
|
@ -69,7 +69,7 @@ func Logger() HandlerFunc {
|
|||||||
latency := end.Sub(start)
|
latency := end.Sub(start)
|
||||||
stdlogger.Printf("[GIN] %v |%s %3d %s| %12v | %s %4s %s\n",
|
stdlogger.Printf("[GIN] %v |%s %3d %s| %12v | %s %4s %s\n",
|
||||||
end.Format("2006/01/02 - 15:04:05"),
|
end.Format("2006/01/02 - 15:04:05"),
|
||||||
color, c.Writer.Status(), reset,
|
color, code, reset,
|
||||||
latency,
|
latency,
|
||||||
requester,
|
requester,
|
||||||
c.Req.Method, c.Req.URL.Path,
|
c.Req.Method, c.Req.URL.Path,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user