Documentation
¶
Overview ¶
Package form implements encoding and decoding of application/x-www-form-urlencoded data.
Index ¶
- func DecodeString(dst interface{}, src string) error
- func DecodeValues(dst interface{}, vs url.Values) error
- func EncodeToString(dst interface{}, needEmptyValue ...bool) (string, error)
- func EncodeToStringWith(dst interface{}, d rune, e rune, z bool) (string, error)
- func EncodeToValues(dst interface{}, needEmptyValue ...bool) (url.Values, error)
- func EncodeToValuesWith(dst interface{}, d rune, e rune, z bool) (url.Values, error)
- type Decoder
- func (d Decoder) Decode(dst interface{}) error
- func (d Decoder) DecodeString(dst interface{}, src string) error
- func (d Decoder) DecodeValues(dst interface{}, vs url.Values) error
- func (d *Decoder) DelimitWith(r rune) *Decoder
- func (d *Decoder) EscapeWith(r rune) *Decoder
- func (d *Decoder) IgnoreCase(ignoreCase bool)
- func (d *Decoder) IgnoreUnknownKeys(ignoreUnknown bool)
- func (d *Decoder) MaxDepth(maxDepth int) *Decoder
- func (d *Decoder) MaxSize(maxSize int) *Decoder
- type Encoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeString ¶
DecodeString decodes src into dst.
func DecodeValues ¶
DecodeValues decodes vs into dst.
func EncodeToString ¶
EncodeToString encodes dst as a form and returns it as a string.
func EncodeToStringWith ¶ added in v1.7.0
EncodeToStringWith encodes dst as a form with delimiter d, escape e, keeping zero values if z, and returns it as a string.
func EncodeToValues ¶
EncodeToValues encodes dst as a form and returns it as Values.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder decodes data from a form (application/x-www-form-urlencoded).
func (Decoder) DecodeString ¶
DecodeString decodes src into dst.
func (Decoder) DecodeValues ¶
DecodeValues decodes vs into dst.
func (*Decoder) DelimitWith ¶
DelimitWith sets r as the delimiter used for composite keys by Decoder d and returns the latter; it is '.' by default.
func (*Decoder) EscapeWith ¶
EscapeWith sets r as the escape used for delimiters (and to escape itself) by Decoder d and returns the latter; it is '\\' by default.
func (*Decoder) IgnoreCase ¶
IgnoreCase if set to true it will make the Decoder try to set values in the destination object even if the case does not match.
func (*Decoder) IgnoreUnknownKeys ¶
IgnoreUnknownKeys if set to true it will make the Decoder ignore values that are not found in the destination object instead of returning an error.
func (*Decoder) MaxDepth ¶ added in v1.7.2
MaxDepth overrides the maximum key-path nesting depth the Decoder will parse, guarding against stack exhaustion and nested-map blow-up from a single key with many delimiters (e.g. "a.a.a.…=x"). Legitimate nesting is bounded by the destination type, so the default sits far above any real form. A value > 0 sets the limit; a value < 0 disables it (trusted input only); the zero value uses the built-in default.
func (*Decoder) MaxSize ¶ added in v1.7.2
MaxSize overrides how large a slice the Decoder will grow in response to an explicit index in the input, guarding against memory exhaustion from a small payload with a very large index (e.g. "Foo.900000000=x").
By default (the zero value) the Decoder uses a bound proportional to the number of elements actually supplied, so legitimately large slices decode while amplification is prevented; most callers never need this method. A value > 0 sets a fixed absolute cap instead (use a large value to permit large sparse slices in trusted input, or a small one to tighten the limit). A value < 0 disables the bound entirely; only do this for fully trusted input.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder provides a way to encode to a Writer.
func (*Encoder) DelimitWith ¶
DelimitWith sets r as the delimiter used for composite keys by Encoder e and returns the latter; it is '.' by default.
func (*Encoder) EscapeWith ¶
EscapeWith sets r as the escape used for delimiters (and to escape itself) by Encoder e and returns the latter; it is '\\' by default.
