Generic REST access. Any GitHub REST path is reachable through get/3,
post/3, patch/3, put/3, and delete/3.
Every call returns {:ok, body, meta} on a 2xx or {:error, reason} otherwise,
where reason is a GhEx.Error for an API error response or a Req exception for
a transport failure. meta is a GhEx.REST.Meta struct carrying the status,
response headers, parsed pagination links, and rate-limit snapshot.
Options
Per-call options are passed through to Req, so the useful ones are:
:params- query string parameters, e.g.params: [state: "open", per_page: 100]:json- a body to JSON-encode forpost/patch/put
Examples
GhEx.REST.get(client, "/repos/elixir-lang/elixir")
GhEx.REST.get(client, "/repos/o/r/issues", params: [state: "open"])
GhEx.REST.post(client, "/repos/o/r/issues", json: %{title: "Bug", body: "..."})
Summary
Types
@type meta() :: GhEx.REST.Meta.t()
@type result() :: {:ok, term(), meta()} | {:error, GhEx.Error.t() | Exception.t()}
Functions
@spec delete(GhEx.Client.t(), String.t(), keyword()) :: result()
Issues a DELETE.
@spec get(GhEx.Client.t(), String.t(), keyword()) :: result()
Issues a GET.
@spec patch(GhEx.Client.t(), String.t(), keyword()) :: result()
Issues a PATCH.
@spec post(GhEx.Client.t(), String.t(), keyword()) :: result()
Issues a POST.
@spec put(GhEx.Client.t(), String.t(), keyword()) :: result()
Issues a PUT.
@spec stream(GhEx.Client.t(), String.t(), keyword()) :: Enumerable.t()
Auto-paginates a list endpoint into a lazy Stream of individual items.
Follows the Link: rel="next" header until GitHub stops handing one back.
The first page's :params are applied once; subsequent pages use the exact
next URL GitHub returns, so cursors are never double-applied. A failed page
raises GhEx.Error.
client
|> GhEx.REST.stream("/repos/elixir-lang/elixir/issues", params: [state: "all", per_page: 100])
|> Stream.map(& &1["number"])
|> Enum.take(250)