Documentation ¶
Index ¶
- Variables
- func DisallowUnknownFields() func(*JSONBinder)
- func EnableUseNumber() func(*JSONBinder)
- func JSONDecodingErrMsg(msg string) func(*JSONBinder)
- func XMLDecodingErrMsg(msg string) func(*XMLBinder)
- func YAMLDecodingErrMsg(msg string) func(*YAMLBinder)
- type Binding
- type BindingSrc
- type JSONBinder
- type Validate
- type XMLBinder
- type YAMLBinder
Constants ¶
This section is empty.
Variables ¶
var JSON = NewJSON()
JSON default JSON binder.
var XML = NewXML()
XML default XML binder.
var YAML = NewYAML()
YAML default YAML binder.
Functions ¶
func DisallowUnknownFields ¶
func DisallowUnknownFields() func(*JSONBinder)
DisallowUnknownFields causes the Decoder to return an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination.
func EnableUseNumber ¶
func EnableUseNumber() func(*JSONBinder)
EnableUseNumber is used to call the UseNumber method on the JSON Decoder instance. UseNumber causes the Decoder to unmarshal a number into an interface{} as a Number instead of as a float64.
func JSONDecodingErrMsg ¶
func JSONDecodingErrMsg(msg string) func(*JSONBinder)
JSONDecodingErrMsg sets the error message output when json.Decode fails to decode an object.
func XMLDecodingErrMsg ¶
XMLDecodingErrMsg sets the error message output when xml.Decode fails to decode an object.
func YAMLDecodingErrMsg ¶
func YAMLDecodingErrMsg(msg string) func(*YAMLBinder)
YAMLLDecodingErrMsg sets the error message output when yaml.Decode fails to decode an object.
Types ¶
type Binding ¶
Binding describes the interface which needs to be implemented for binding the data present in the request such as JSON request body, query parameters or the form POST.
type BindingSrc ¶
BindingSrc reads passes body from supplied source instead of a request.
type JSONBinder ¶
type JSONBinder struct {
// contains filtered or unexported fields
}
JSONBinder bind the json encoded data present in the request. It implements the Binding and BindingBody interface.
func NewJSON ¶
func NewJSON(opts ...func(*JSONBinder)) *JSONBinder
NewJSON returns a new JSONRender responder instance.
func (*JSONBinder) FromReq ¶
func (b *JSONBinder) FromReq(req *http.Request, obj interface{}) error
Bind the JSON request body to an object, if the object implements Validate the valid method will be called.
func (*JSONBinder) FromSrc ¶
func (b *JSONBinder) FromSrc(body []byte, obj interface{}) error
Bind the JSON body to an object, if the object implements Validate the valid method will be called.
type Validate ¶
type Validate interface {
Validate() error
}
Validate represents types capable of validating themselves.
type XMLBinder ¶
type XMLBinder struct {
// contains filtered or unexported fields
}
XMLBinder bind the xml encoded data present in the request. It implements the Binding and BindingBody interface.
type YAMLBinder ¶
type YAMLBinder struct {
// contains filtered or unexported fields
}
YAMLBinder bind the yaml encoded data present in the request. It implements the Binding and BindingBody interface.
func NewYAML ¶
func NewYAML(opts ...func(*YAMLBinder)) *YAMLBinder
NewYAML returns a new YAMLBinder responder instance.
func (*YAMLBinder) FromReq ¶
func (b *YAMLBinder) FromReq(req *http.Request, obj interface{}) error
Bind the YAML request body to an object, if the object implements Validate the valid method will be called.
func (*YAMLBinder) FromSrc ¶
func (b *YAMLBinder) FromSrc(body []byte, obj interface{}) error
Bind the YAML body to an object, if the object implements Validate the valid method will be called.