Documentation ¶
Overview ¶
Package binding ...
Index ¶
- Constants
- Variables
- func Bind(i interface{}, r Request) error
- func BindForm(i interface{}, r Request) error
- func BindJSON(i interface{}, r Request) error
- func BindMultipartForm(i interface{}, r Request) error
- func BindXML(i interface{}, r Request) error
- func RegisterBodyBinder(mime string, binder BodyBinder)
- func RegisterConverter(typ reflect.Type, converter FieldConverter)
- func RegisterValidator(validator func(i interface{}) error)
- type BindScope
- type BodyBinder
- type FieldConverter
- type Request
Constants ¶
View Source
const ( MIMEApplicationJSON = "application/json" MIMEApplicationXML = "application/xml" MIMETextXML = "text/xml" MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEMultipartForm = "multipart/form-data" )
Variables ¶
View Source
var ErrBinding = errors.New("binding failed")
View Source
var ErrValidate = errors.New("validate failed")
Functions ¶
func Bind ¶
Bind checks the Method and Content-Type to select a binding engine automatically, Depending on the "Content-Type" header different bindings are used, for example:
"application/json" --> JSON binding "application/xml" --> XML binding
func BindMultipartForm ¶
func RegisterBodyBinder ¶
func RegisterBodyBinder(mime string, binder BodyBinder)
RegisterBodyBinder register body binder.
func RegisterConverter ¶
func RegisterConverter(typ reflect.Type, converter FieldConverter)
RegisterConverter register custom field type converter.
func RegisterValidator ¶
func RegisterValidator(validator func(i interface{}) error)
RegisterValidator register custom validator.
Types ¶
type BodyBinder ¶
type Request ¶
type Request interface { ContentType() string Header(key string) (string, bool) Cookie(name string) (string, bool) PathParam(name string) (string, bool) QueryParam(name string) (string, bool) FormParams() (url.Values, error) MultipartParams(maxMemory int64) (*multipart.Form, error) RequestBody() io.Reader }
Click to show internal directories.
Click to hide internal directories.