PgRest.Request.Range (PgRest v0.2.0)

Copy Markdown View Source

Combines the Range header with the limit/offset query parameters into a single %{offset, limit}, porting PostgREST's getRanges.

Ranges are inclusive {lower, upper} row intervals where upper may be :inf. The header range is intersected with the limit/offset range; an empty result is a 416 PGRST103, except for the special limit=0 range {0, -1} which means "no rows". Only GET honors the Range header (HEAD does not), as recorded from PostgREST.

Summary

Functions

Computes the effective offset and limit for a request.

Types

t()

@type t() :: %{offset: non_neg_integer(), limit: non_neg_integer() | nil}

Functions

from(method, headers, params)

@spec from(String.t(), [{String.t(), String.t()}], [{String.t(), String.t()}]) ::
  {:ok, t()} | {:error, PgRest.Error.t()}

Computes the effective offset and limit for a request.