Content types & negotiation

The runtime ships codecs for JSON, XML, CSV, plain text, byte streams and YAML (core / content-types). Anything beyond that — a different format, vendor MIME types, large streaming bodies, per-payload Content-Type overrides — is a few lines of glue.

The pages below each tackle one such glue case.

  • Register a Consumer and Producer for a wire format the runtime does not ship — using MessagePack as the worked example.
  • Versioning an API through vendor MIME types (application/vnd.acme.v1+json) — separate registrations per type, shared codec.
  • ByteStreamConsumer and ByteStreamProducer for large up- and downloads — without buffering the whole payload in memory.
  • Use server-middleware/negotiate from a vanilla net/http handler — no OpenAPI spec, no go-openapi/runtime dependency.