Documentation
¶
Overview ¶
Package jsonapi provides HTTP middleware that transforms Vanguard REST responses into [JSON:API](https://jsonapi.org/format/) envelopes with the foundation/jsonapi codec.
Only REST requests are transformed (IsRESTRequest); Connect, gRPC, and gRPC-Web pass through unchanged. The middleware sits between the HTTP server and Vanguard, rewriting response bodies into {data, meta, links, errors} and validating/unwrapping the inbound {data:{type,attributes}} request envelope, by the Role of the route the consumer's table (codec.Config) matches.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRESTRequest ¶
IsRESTRequest returns true if the request appears to be a REST request (not Connect, gRPC, or gRPC-Web).
func Middleware ¶
Middleware wraps an http.Handler with JSON:API response/request transformation, driven by the generated operation-keyed route table. Only REST requests are transformed; Connect, gRPC, and gRPC-Web pass through unchanged.
Request handling order is match-first: the route is resolved by (method, path) before any body handling, so an unmatched path passes through untouched. A matched CREATE/UPDATE route validates + unwraps the inbound {data:{type,attributes}} envelope (400 before the handler on a malformed, absent, or type-mismatched envelope); other roles pass their body through. The response is then transformed by the route's codec.Role — never by guessing method/path/data-presence.
Types ¶
This section is empty.