wire

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package wire is how this repository's services speak JSON.

The reference promises snake_case JSON — `occurred_at`, `tenant_id` — and the archive has always been written that way. The services were not: connect-go's default JSON codec writes lowerCamelCase, so a response said `occurredAt` where the reference, the archive and every exported file say `occurred_at`. It went unnoticed because reading is lenient — protojson accepts either spelling on the way in — and because Go clients speak binary protobuf, where names do not exist. Only a JSON reader saw it: a browser, the viewer, curl.

HandlerOptions is the fix, and every handler in this repository applies it before the caller's own options, so that none of them is the one that forgot and a deployment can still override it deliberately.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandlerOptions

func HandlerOptions() []connect.HandlerOption

HandlerOptions make a handler write snake_case JSON, under both names a Connect client may ask for JSON by.

Types

type Codec

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

Codec is protojson with the proto's own field names on output.

Input is unchanged from connect-go's own codec: either spelling is accepted and unknown fields are discarded, so that a client one schema version ahead is not refused. Only what this side writes is fixed.

func (Codec) IsBinary

func (Codec) IsBinary() bool

IsBinary implements connect's optional binary marker.

func (Codec) Marshal

func (Codec) Marshal(message any) ([]byte, error)

Marshal implements connect.Codec.

func (Codec) MarshalAppend

func (Codec) MarshalAppend(dst []byte, message any) ([]byte, error)

MarshalAppend implements connect's optional append codec.

func (Codec) MarshalStable

func (c Codec) MarshalStable(message any) ([]byte, error)

MarshalStable implements connect's optional stable codec, which GET requests use as a cache key. protojson's whitespace is not stable, so it is compacted.

func (Codec) Name

func (c Codec) Name() string

Name implements connect.Codec.

func (Codec) Unmarshal

func (Codec) Unmarshal(data []byte, message any) error

Unmarshal implements connect.Codec.

Jump to

Keyboard shortcuts

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