Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultCodecKey = "default_codec_key"
Variables ¶
View Source
var ErrNoEncoderAvailable = errors.New("codec not available")
ErrNoEncoderAvailable communicates that a codec is not available.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec struct { NewEncoder func(w io.Writer) Encoder NewDecoder func(r io.Reader) Decoder MimeTypes []string }
Codec combines an encoder, a decoder and a list of mime types.
type Decoder ¶
type Decoder interface { // Decode decodes encoded value from the input stream into v. Decode(v interface{}) error }
Decoder decodes encoded value from a input stream.
func ContentTypeDecoder ¶
ContentTypeDecoder decodes the encoded data from r based on the Content-Type header value and the codecs that are available. If no codec is found, it returns a ErrNoEncoderAvailable.
type EditMode ¶
type EditMode bool
EditMode allows to select an editable version of a codec. eg. HTML Forms for HTML codec
type Encoder ¶
type Encoder interface { // Encode writes the codec data of v to the output stream. Encode(v interface{}) error }
Encoder writes encoded value to an output stream.
func AcceptEncoder ¶
func AcceptEncoder(w http.ResponseWriter, acceptHeader string, edit EditMode, codecs Codecs) Encoder
AcceptEncoder creates an new encoder for w based on the acceptHeader, the edit mode and the codecs that are available.
type RequestResponseWriter ¶ added in v0.8.0
type RequestResponseWriter struct { http.ResponseWriter Request *http.Request }
Click to show internal directories.
Click to hide internal directories.