codecs

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Decoder
	Encoder
}

Codec embeds both Decoder and Encoder.

var Binary Codec = codecBinary{}

Binary codec encodes and decodes binary requests and responses. Decode/Unmarshal accepts an io.Writer and copies content to the writer. Encode/Marshal accepts an io.Reader and copies content from the reader.

var FormURLEncoded Codec = codecFormURLEncoded{}

FormURLEncoded (de)serializes Form parameters.

var JSON Codec = codecJSON{}

JSON codec encodes and decodes JSON requests and responses using github.com/palantir/pkg/safejson. On Decode, it sets UseNumber on the json.Decoder to account for large numbers. On Encode, we disable HTML escaping, which for bad reasons (as acknowledged by go team), is default-enabled.

var Plain Codec = codecPlain{}

Plain implements a text/plain codec. Values used to marshal/unmarshal must be of type string or encoding.TextMarshaler/encoding.TextUnmarshaler.

func ZLIB

func ZLIB(codec Codec) Codec

ZLIB wraps an existing Codec and uses zlib for compression and decompression.

type Decoder

type Decoder interface {
	Accept() string
	Decode(r io.Reader, v interface{}) error
	Unmarshal(data []byte, v interface{}) error
}

A Decoder decodes a serialized message.

type Encoder

type Encoder interface {
	ContentType() string
	Encode(w io.Writer, v interface{}) error
	Marshal(v interface{}) ([]byte, error)
}

An Encoder serializes a message.

Jump to

Keyboard shortcuts

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