Help us shape the future of Go! Take the 2026 Go Developer Survey

codec

package
v1.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package codec decodes gRPC, Connect, and bare protobuf payloads to JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec struct {
	// contains filtered or unexported fields
}

Codec owns the descriptors used only for protobuf wire decoding.

func New

func New(loaded *schema.Schema, set *descriptorpb.FileDescriptorSet) (*Codec, error)

New constructs a codec and checks that the declarations match its descriptors.

func (*Codec) Decode

func (c *Codec) Decode(name schema.TypeRef, format Format, header http.Header, body []byte, maxBodyBytes int) (any, error)

Decode converts a payload into the ProtoJSON shape of its declared type.

func (*Codec) Streaming

func (c *Codec) Streaming(name string) bool

Streaming reports whether name refers to a streaming protobuf method.

type Format

type Format int

Format identifies the protobuf wire representation.

const (
	// ConnectJSON is unframed ProtoJSON.
	ConnectJSON Format = iota + 1
	// GRPC is one unary gRPC frame.
	GRPC
	// Protobuf is a bare protobuf message.
	Protobuf
)

Jump to

Keyboard shortcuts

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