Documentation
¶
Overview ¶
Package formam decodes HTTP form and query parameters.
Index ¶
Constants ¶
View Source
const ( ErrCodeNotAPointer uint8 = iota // Didn't pass a pointer to Decode(). ErrCodeArrayIndex // Error attempting to use an array index (e.g. foo[2]). ErrCodeConversion // Error converting field to the type. ErrCodeUnknownType // Unknown type. ErrCodeUnknownField // No struct field for passed parameter (will never be used if IgnoreUnknownKeys is set). ErrCodeRange // Number is out of range (e.g. parsing 300 in uint8 would overflow). ErrCodeArraySize // Array longer than MaxSize. )
Error codes.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DecodeCustomTypeFunc ¶
DecodeCustomTypeFunc for decoding a custom type.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder to decode a form.
func NewDecoder ¶
func NewDecoder(opts *DecoderOptions) *Decoder
NewDecoder creates a new instance of Decoder.
func (Decoder) Decode ¶
Decode the url.Values and populate the destination dst, which must be a pointer.
func (*Decoder) RegisterCustomType ¶
func (dec *Decoder) RegisterCustomType(fn DecodeCustomTypeFunc, types []interface{}, fields []interface{}) *Decoder
RegisterCustomType registers a functions for decoding custom types.
type DecoderOptions ¶
type DecoderOptions struct {
// Struct field tag name; default is "formam".
TagName string
// Prefer UnmarshalText over custom types.
PrefUnmarshalText bool
// Disable UnmarshalText interface
DisableUnmarshalText bool
// Ignore unknown form fields. By default unknown fields are an error
// (although all valid keys will still be decoded).
IgnoreUnknownKeys bool
// The maximum array size that formam will create. This is limited to
// prevent malicious input to create huge arrays to starve the server of
// memory.
//
// The default is 16,000; set to -1 to disable.
MaxSize int
}
DecoderOptions options for decoding the values.
Click to show internal directories.
Click to hide internal directories.

