marshal

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const JSONContentType = "application/json"
View Source
const ProtobufContentType = "application/x-protobuf"

Variables

View Source
var DefaultMarshallerRegistry = map[string]Marshaller{}
View Source
var JSONMarshaller = &JsonMarshaller{}
View Source
var ProtobufMarshaller = &ProtoMarshaller{}

Functions

func RegisterMarshaller

func RegisterMarshaller(marshaller Marshaller)

Types

type JsonMarshaller

type JsonMarshaller struct {
}

func (*JsonMarshaller) ContentType

func (j *JsonMarshaller) ContentType() string

func (*JsonMarshaller) Marshal

func (j *JsonMarshaller) Marshal(v interface{}) ([]byte, error)

func (*JsonMarshaller) Unmarshal

func (j *JsonMarshaller) Unmarshal(data []byte, v interface{}) error

type Marshaller

type Marshaller interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
	ContentType() string
}

type ProtoMarshaller

type ProtoMarshaller struct {
}

func (*ProtoMarshaller) ContentType

func (p *ProtoMarshaller) ContentType() string

func (*ProtoMarshaller) Marshal

func (p *ProtoMarshaller) Marshal(v interface{}) ([]byte, error)

func (*ProtoMarshaller) Unmarshal

func (p *ProtoMarshaller) Unmarshal(data []byte, v interface{}) error

Jump to

Keyboard shortcuts

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