codec

package
v1.1.22 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplicationJson  = "application/json"
	ApplicationProto = "application/proto"
)

Variables

View Source
var DefaultCodecs = map[string]Codec{
	"application/json":     jsonc.JSCodec,
	"application/proto":    &protoc.Proto{},
	"application/protobuf": &protoc.Proto{},
}

Functions

func SetCodec added in v1.0.6

func SetCodec(contentType string, c Codec)

Types

type Codec

type Codec interface {
	Encode(message proto.Message) ([]byte, error)
	Decode(b []byte, message proto.Message) error
	MustEncodeString(message proto.Message) string
	MustEncode(message proto.Message) []byte
	MustDecode(b []byte, message proto.Message)
	Name() string
}

func CodecType added in v1.0.9

func CodecType(contentType string) Codec

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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