form – github.com/ajg/form Index | Files

package form

import "github.com/ajg/form"

Package form implements encoding and decoding of application/x-www-form-urlencoded data.

Index

Functions

func DecodeString

func DecodeString(dst interface{}, src string) error

DecodeString decodes src into dst.

func DecodeValues

func DecodeValues(dst interface{}, vs url.Values) error

DecodeValues decodes vs into dst.

func EncodeToString

func EncodeToString(dst interface{}) (string, error)

EncodeToString encodes dst as a form and returns it as a string.

func EncodeToValues

func EncodeToValues(dst interface{}) (url.Values, error)

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 NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new form Decoder.

func (Decoder) Decode

func (d Decoder) Decode(dst interface{}) error

Decode reads in and decodes form-encoded data into dst.

func (Decoder) DecodeString

func (d Decoder) DecodeString(dst interface{}, src string) error

DecodeString decodes src into dst.

func (Decoder) DecodeValues

func (d Decoder) DecodeValues(dst interface{}, vs url.Values) error

DecodeValues decodes vs into dst.

func (*Decoder) DelimitWith

func (d *Decoder) DelimitWith(r rune) *Decoder

DelimitWith sets r as the delimiter used for composite keys by Decoder d and returns the latter; it is '.' by default.

func (*Decoder) EscapeWith

func (d *Decoder) EscapeWith(r rune) *Decoder

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

func (d *Decoder) IgnoreCase(ignoreCase bool)

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

func (d *Decoder) IgnoreUnknownKeys(ignoreUnknown bool)

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.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder provides a way to encode to a Writer.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new form Encoder.

func (*Encoder) DelimitWith

func (e *Encoder) DelimitWith(r rune) *Encoder

DelimitWith sets r as the delimiter used for composite keys by Encoder e and returns the latter; it is '.' by default.

func (Encoder) Encode

func (e Encoder) Encode(dst interface{}) error

Encode encodes dst as form and writes it out using the Encoder's Writer.

func (*Encoder) EscapeWith

func (e *Encoder) EscapeWith(r rune) *Encoder

EscapeWith sets r as the escape used for delimiters (and to escape itself) by Encoder e and returns the latter; it is '\\' by default.

func (*Encoder) KeepZeros

func (e *Encoder) KeepZeros(z bool) *Encoder

KeepZeros sets whether Encoder e should keep zero (default) values in their literal form when encoding, and returns the former; by default zero values are not kept, but are rather encoded as the empty string.

Source Files

decode.go encode.go form.go node.go

Version
v1.5.1 (latest)
Published
Mar 18, 2019
Platform
windows/amd64
Imports
10 packages
Last checked
now

Tools for package owners.