crux_rest v0.1.3 Crux.Rest.Handler View Source

Handles per route rate limiting.

All functions in Crux.Rest automatically use this module, you do not need to worry about it.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Queues a request, waits if necessary, and executes it.
Blocks the calling process

Starts a rate limit handler for the provided route

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function queue(request) View Source
queue({String.t(), list()}) ::
  term()
  | {:error, HTTPoison.Error.t()}
  | {:error, {:decoding, :invalid | {:invalid, String.t()}}}

Queues a request, waits if necessary, and executes it.
Blocks the calling process.

Returns parsed response body on success.

First element of the tuple is the route of the request.
The second element is list of parameters passed via :erlang.apply/3 to HTTPoison.Base.request/5.

For the non API errors see HTTPPoison.Base.request/5 and Poison.decode/2.

Link to this function start_link(route) View Source
start_link(route :: String.t()) :: GenServer.on_start()

Starts a rate limit handler for the provided route.