chore(vendor): upgrade gin repo (#249)

This commit is contained in:
Bo-Yi Wu
2017-07-14 22:23:57 -05:00
committed by GitHub
parent 02f0390d4d
commit 6a64b42ab0
69 changed files with 8967 additions and 298 deletions

View File

@@ -48,19 +48,19 @@ var (
func Default(method, contentType string) Binding {
if method == "GET" {
return Form
} else {
switch contentType {
case MIMEJSON:
return JSON
case MIMEXML, MIMEXML2:
return XML
case MIMEPROTOBUF:
return ProtoBuf
case MIMEMSGPACK, MIMEMSGPACK2:
return MsgPack
default: //case MIMEPOSTForm, MIMEMultipartPOSTForm:
return Form
}
}
switch contentType {
case MIMEJSON:
return JSON
case MIMEXML, MIMEXML2:
return XML
case MIMEPROTOBUF:
return ProtoBuf
case MIMEMSGPACK, MIMEMSGPACK2:
return MsgPack
default: //case MIMEPOSTForm, MIMEMultipartPOSTForm:
return Form
}
}

View File

@@ -1,3 +1,7 @@
// Copyright 2017 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package binding
import (

View File

@@ -153,6 +153,11 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
return errors.New("Blank time format")
}
if val == "" {
value.Set(reflect.ValueOf(time.Time{}))
return nil
}
l := time.Local
if isUTC, _ := strconv.ParseBool(structField.Tag.Get("time_utc")); isUTC {
l = time.UTC

View File

@@ -5,9 +5,14 @@
package binding
import (
"encoding/json"
"net/http"
"github.com/json-iterator/go"
)
var (
json = jsoniter.ConfigCompatibleWithStandardLibrary
EnableDecoderUseNumber = false
)
type jsonBinding struct{}
@@ -18,6 +23,9 @@ func (jsonBinding) Name() string {
func (jsonBinding) Bind(req *http.Request, obj interface{}) error {
decoder := json.NewDecoder(req.Body)
if EnableDecoderUseNumber {
decoder.UseNumber()
}
if err := decoder.Decode(obj); err != nil {
return err
}

View File

@@ -5,10 +5,10 @@
package binding
import (
"github.com/golang/protobuf/proto"
"io/ioutil"
"net/http"
"github.com/golang/protobuf/proto"
)
type protobufBinding struct{}