Refactors binding module

This commit is contained in:
Manu Mtz-Almeida
2015-03-31 17:51:10 +02:00
parent 18880f9215
commit d4413b6e91
10 changed files with 367 additions and 299 deletions

14
gin.go
View File

@ -9,19 +9,11 @@ import (
"net/http"
"sync"
"github.com/gin-gonic/gin/binding"
"github.com/gin-gonic/gin/render"
"github.com/julienschmidt/httprouter"
)
const (
MIMEJSON = "application/json"
MIMEHTML = "text/html"
MIMEXML = "application/xml"
MIMEXML2 = "text/xml"
MIMEPlain = "text/plain"
MIMEPOSTForm = "application/x-www-form-urlencoded"
MIMEMultipartPOSTForm = "multipart/form-data"
)
type (
HandlerFunc func(*Context)
@ -147,7 +139,7 @@ func (engine *Engine) handle404(w http.ResponseWriter, req *http.Request) {
c.Next()
if !c.Writer.Written() {
if c.Writer.Status() == 404 {
c.Data(-1, MIMEPlain, engine.Default404Body)
c.Data(-1, binding.MIMEPlain, engine.Default404Body)
} else {
c.Writer.WriteHeaderNow()
}
@ -162,7 +154,7 @@ func (engine *Engine) handle405(w http.ResponseWriter, req *http.Request) {
c.Next()
if !c.Writer.Written() {
if c.Writer.Status() == 405 {
c.Data(-1, MIMEPlain, engine.Default405Body)
c.Data(-1, binding.MIMEPlain, engine.Default405Body)
} else {
c.Writer.WriteHeaderNow()
}