Documentation ¶
Index ¶
- type BindUnmarshaler
- type Binder
- type DefaultBinder
- func (b *DefaultBinder) Bind(i interface{}, c echo.Context) (err error)
- func (b *DefaultBinder) BindBody(c echo.Context, i interface{}) (err error)
- func (b *DefaultBinder) BindHeaders(c echo.Context, i interface{}) error
- func (b *DefaultBinder) BindPathParams(c echo.Context, i interface{}) error
- func (b *DefaultBinder) BindQueryParams(c echo.Context, i interface{}) error
- type StructValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BindUnmarshaler ¶
type BindUnmarshaler interface { // UnmarshalParam decodes and assigns a value from an form or query param. UnmarshalParam(param string) error }
BindUnmarshaler is the interface used to wrap the UnmarshalParam method. Types that don't implement this, but do implement encoding.TextUnmarshaler will use that interface instead.
type Binder ¶
type Binder interface {
Bind(i interface{}, c echo.Context) error
}
Binder is the interface that wraps the Bind method.
type DefaultBinder ¶
type DefaultBinder struct{}
DefaultBinder is the default implementation of the Binder interface.
func (*DefaultBinder) Bind ¶
func (b *DefaultBinder) Bind(i interface{}, c echo.Context) (err error)
Bind implements the `Binder#Bind` function. Binding is done in following order: 1) path params; 2) query params; 3) request body. Each step COULD override previous step binded values. For single source binding use their own methods BindBody, BindQueryParams, BindPathParams.
func (*DefaultBinder) BindBody ¶
func (b *DefaultBinder) BindBody(c echo.Context, i interface{}) (err error)
BindBody binds request body contents to bindable object NB: then binding forms take note that this implementation uses standard library form parsing which parses form data from BOTH URL and BODY if content type is not MIMEMultipartForm See non-MIMEMultipartForm: https://golang.org/pkg/net/http/#Request.ParseForm See MIMEMultipartForm: https://golang.org/pkg/net/http/#Request.ParseMultipartForm
func (*DefaultBinder) BindHeaders ¶
func (b *DefaultBinder) BindHeaders(c echo.Context, i interface{}) error
BindHeaders binds HTTP headers to a bindable object
func (*DefaultBinder) BindPathParams ¶
func (b *DefaultBinder) BindPathParams(c echo.Context, i interface{}) error
BindPathParams binds path params to bindable object
func (*DefaultBinder) BindQueryParams ¶
func (b *DefaultBinder) BindQueryParams(c echo.Context, i interface{}) error
BindQueryParams binds query params to bindable object
type StructValidator ¶
type StructValidator interface { // ValidateStruct can receive any kind of type and it should never panic, even if the configuration is not right. // If the received type is not a struct, any validation should be skipped and nil must be returned. // If the received type is a struct or pointer to a struct, the validation should be performed. // If the struct is not valid or the validation itself fails, a descriptive error should be returned. // Otherwise nil must be returned. ValidateStruct(interface{}) error }
var Validator StructValidator = &defaultValidator{}