encoding

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ContentTypeJSON is json codec name.
	ContentTypeJSON = "json"
	// ContentTypeProto is proto codec name.
	ContentTypeProto = "proto"
)

Variables

This section is empty.

Functions

func RegisterCodec

func RegisterCodec(c Codec)

RegisterCodec registers the provided Codec for use with all gRPC clients and servers.

The Codec will be stored and looked up by result of its Name() method, which should match the content-subtype of the encoding handled by the Codec. This is case-insensitive, and is stored and looked up as lowercase. If the result of calling Name() is an empty string, RegisterCodec will panic. See Content-Type on https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for more details.

NOTE: this function must only be called during initialization time (i.e. in an init() function), and is not thread-safe. If multiple Codec are registered with the same name, the one registered last will take effect.

Types

type Codec

type Codec = encoding.Codec

Codec defines the interface uses to encode and decode messages. Note that implementations of this interface must be thread safe; a Codec's methods can be called from concurrent goroutines.

func GetCodec

func GetCodec(subContentType string) Codec

GetCodec gets a registered Codec by content-subtype, or nil if no Codec is registered for the content-subtype.

The content-subtype is expected to be lowercase.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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