codec

package
v0.55.2 Latest Latest
Warning

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

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

Documentation

Overview

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

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 for protobuf wire decoding and encoding.

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) Encode added in v0.55.0

func (c *Codec) Encode(name schema.TypeRef, value any) ([]byte, error)

Encode converts a ProtoJSON value of its declared type into a bare protobuf message.

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