PostgREST custom media-type handlers.
A custom media type is a DOMAIN whose name is the MIME string; a handler is
an aggregate whose transition-state type is that domain. The aggregate's first
argument is the relation (or anyelement) it applies to. A function returning
a media-type domain is the "Any"/per-result handler.
When a request's Accept matches a handler for the target relation/RPC, the
handler runs in SQL and its (already-serialized) output becomes the response
body, with the domain's MIME as the Content-Type.
Summary
Functions
Try to satisfy a relation GET via a custom media handler aggregate keyed on
the relation. Returns a Plug.Conn if handled, or :no_handler.
Try to satisfy an RPC via a custom handler: either the function itself returns
a media-type domain (the "Any"/scalar handler), or an anyelement aggregate
applies to the function's result. Returns a Plug.Conn or :no_handler.
Functions
Try to satisfy a relation GET via a custom media handler aggregate keyed on
the relation. Returns a Plug.Conn if handled, or :no_handler.
lookupHandler gates BOTH of its relation-keyed probes behind
when' defaultSelect (Plan/Negotiate.hs#L76-L77): a relation-scoped handler
aggregates the relation's whole ROW type, so it can only serve a request that
projects the default select list. An explicit ?select= drops it out of
negotiation entirely and the request falls back to the built-in producers —
which, for a media type none of them emits, is a 406 (case 1646).
Try to satisfy an RPC via a custom handler: either the function itself returns
a media-type domain (the "Any"/scalar handler), or an anyelement aggregate
applies to the function's result. Returns a Plug.Conn or :no_handler.