epcoding

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NoTemplateSpecified is returned when an output that wants to be encoded
	// doesn't specify a template
	NoTemplateSpecified = errors.New("output without method that selects template")
)

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	Decode(v interface{}) error
}

Decoder deserializes a value from the request body

type Decoding

type Decoding interface {
	Accepts() string
	Decoder(r *http.Request) Decoder
}

Decoding describes deocding that accepts a certain content type

func NewForm

func NewForm(uvd URLValuesDecoder) Decoding

NewForm initializes a decoder that parses form request bodies

type Encoder

type Encoder interface {
	Encode(v interface{}) error
}

Encoder serializes a value into the response body

type Encoding

type Encoding interface {
	Produces() string
	Encoder(w http.ResponseWriter) Encoder
}

Encoding describes encoding that procoduces a certain content type

func NewHTML

func NewHTML(t *template.Template) Encoding

NewHTML initializes an html encoder with the provide template(s)

type JSON

type JSON struct{}

JSON encoding and decoding

func (JSON) Accepts

func (_ JSON) Accepts() string

func (JSON) Decoder

func (_ JSON) Decoder(r *http.Request) Decoder

func (JSON) Encoder

func (_ JSON) Encoder(w http.ResponseWriter) Encoder

func (JSON) Produces

func (_ JSON) Produces() string

type URLValuesDecoder

type URLValuesDecoder interface {
	Decode(v interface{}, d url.Values) error
}

URLValuesDecoder can be implemented to automate the decoding of url.Values

type XML

type XML struct{}

XML encoding and decoding

func (XML) Accepts

func (_ XML) Accepts() string

func (XML) Decoder

func (_ XML) Decoder(r *http.Request) Decoder

func (XML) Encoder

func (_ XML) Encoder(w http.ResponseWriter) Encoder

func (XML) Produces

func (_ XML) Produces() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL