encoding

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AvailableEncodings = []string{
	"application/json",
	"text/xml",
	"application/yaml",
	"text/html",
	"application/x-www-form-urlencoded",
	"application/msgpack",
}
View Source
var ErrNoEncoderAvailable = errors.New("codec not available")

Functions

func AvailableCodecs

func AvailableCodecs() map[string]Codec

func RegisterCodec

func RegisterCodec(mime string, codec Codec)

Types

type Codec

type Codec struct {
	NewEncoder NewEncoderFunc
	NewDecoder NewDecoderFunc
}

func WrapCodec

func WrapCodec[E Encoder, EFunc func(w io.Writer) E, D Decoder, DFunc func(r io.Reader) D](encoderFunc EFunc, decoderFunc DFunc) Codec

type Decoder

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

func ContentTypeDecoder

func ContentTypeDecoder(r io.Reader, contentTypeHeader string) Decoder

type EditMode

type EditMode bool
const (
	EditOff EditMode = false
	EditOn  EditMode = true
)

type Encoder

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

func AcceptEncoder

func AcceptEncoder(w http.ResponseWriter, acceptHeader string, edit EditMode) Encoder

type NewDecoderFunc

type NewDecoderFunc func(r io.Reader) Decoder

func WrapDecoder

func WrapDecoder[D Decoder, F func(r io.Reader) D](f F) NewDecoderFunc

type NewEncoderFunc

type NewEncoderFunc func(w io.Writer) Encoder

func WrapEncoder

func WrapEncoder[E Encoder, F func(w io.Writer) E](f F) NewEncoderFunc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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