Documentation ¶
Index ¶
- Constants
- type ContentTypeError
- type ConversionError
- type Converter
- type Decoder
- func (d *Decoder) CollectErrors(c bool)
- func (d *Decoder) Decode(dst interface{}, r *http.Request) error
- func (d *Decoder) DefaultLocation(l int)
- func (d *Decoder) IgnoreUnknownKeys(i bool)
- func (d *Decoder) MaxMemory(m int64)
- func (d *Decoder) NameFunc(n func(field string, locations []int) string)
- func (d *Decoder) PathExtractor(p func(r *http.Request) map[string]string)
- func (d *Decoder) RegisterConverter(value interface{}, converterFunc Converter)
- func (d *Decoder) Separator(left rune, right rune, sep rune)
- func (d *Decoder) ZeroEmpty(z bool)
- type LocationError
- type MultiError
- type ParsingError
- type UnknownKeyError
Constants ¶
const ( LocationPath int LocationQuery LocationHeader LocationForm LocationFile LocationJSON )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentTypeError ¶
func (ContentTypeError) Error ¶
func (e ContentTypeError) Error() string
type ConversionError ¶
type ConversionError struct { Key string // key from the source map. Type reflect.Type // expected type of elem Index int // index for multi-value fields; -1 for single-value fields. Err error // low-level error (when it exists) }
ConversionError stores information about a failed conversion.
func (ConversionError) Error ¶
func (e ConversionError) Error() string
func (ConversionError) Unwrap ¶
func (e ConversionError) Unwrap() error
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder decodes params from a *http.Request to a struct.
func (*Decoder) CollectErrors ¶
CollectErrors specifies whether to return on the first error or accumulate errors.
func (*Decoder) Decode ¶
Decode decodes a *http.Request to a struct.
The first parameter must be a pointer to a struct. The second parameter is a pointer to http.Request.
func (*Decoder) DefaultLocation ¶
DefaultLocation sets the default location to look for params. It is only applied if a field does not have location tags.
func (*Decoder) IgnoreUnknownKeys ¶
IgnoreUnknownKeys controls the behaviour when the decoder encounters unknown keys in the map. If i is true and an unknown field is encountered, it is ignored. This is similar to how unknown keys are handled by encoding/json. If i is false then Decode will return an error. Note that any valid keys will still be decoded in to the target struct.
func (*Decoder) PathExtractor ¶
PathExtractor defines the mechanism to extract path params from URIs. It takes a function that takes a *http.Request and returns map[string]string
func (*Decoder) RegisterConverter ¶
RegisterConverter registers a converter function for a custom type.
func (*Decoder) Separator ¶
Separator defines runes to be used as separators. If given '[', ']', '.' for example, then paths should be like a[b].[0].[c] This is provided to make it possible to accept serialized objects from jQuery for example. Both left and right can be set to 0 if only changing the separator
func (*Decoder) ZeroEmpty ¶
ZeroEmpty controls the behaviour when the decoder encounters empty values in a map. If z is true and a key in the map has the empty string as a value then the corresponding struct field is set to the zero value. If z is false then empty strings are ignored.
The default value is false, that is empty values do not change the value of the struct field.
type LocationError ¶
func (LocationError) Error ¶
func (e LocationError) Error() string
type MultiError ¶
MultiError stores multiple decoding errors.
Borrowed from the App Engine SDK.
func (MultiError) Error ¶
func (e MultiError) Error() string
type ParsingError ¶
func (ParsingError) Error ¶
func (e ParsingError) Error() string
func (ParsingError) Unwrap ¶
func (e ParsingError) Unwrap() error
type UnknownKeyError ¶
type UnknownKeyError struct {
Key string // key from the source map.
}
UnknownKeyError stores information about an unknown key in the source map.
func (UnknownKeyError) Error ¶
func (e UnknownKeyError) Error() string