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) MarshalAppend ¶
MarshalAppend implements connect's optional append codec.
func (Codec) MarshalStable ¶
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.