PgRest.Request.Accept (PgRest v0.2.0)

Copy Markdown View Source

Parses an Accept header into PgRest.MediaTypes, PostgREST's Accept handling.

The header is split on , outside double quotes; each type's parameters on ; outside quotes. As in wai (PostgREST), spaces are dropped and a lowercase ;q= ends the type: its value (default 1.0) orders the types, highest first, ties going to the more specific type (parameters count for it, * against) and then to header order. Parameters read: nulls=stripped (on application/vnd.pgrst.array and application/vnd.pgrst.object only; the name is case-insensitive, the value may be quoted and is case-sensitive), and for the plan type for="<media type>" and options=<name>|<name> (an empty value or a trailing ; is fine: supabase-js sends options=;). Unknown plan options are ignored. A missing header is */*, an empty one no type at all (which PgRest.Negotiate answers with JSON).

Types and parameter names are matched against fixed tables; nothing a client sends becomes an atom.

Summary

Functions

The media types of an Accept header value, by descending q.

Functions

parse(header)

@spec parse(String.t() | nil) :: [PgRest.MediaType.t()]

The media types of an Accept header value, by descending q.