Http (fnord v0.8.82)
View SourceSummary
Functions
Sends a GET request to the specified URL with the given headers and query parameters. Returns a tuple with the response status and body, or an error if the request fails.
Sends a POST request with a JSON payload to the specified URL with the given headers. Returns a tuple with the response status and body, or an error if the request fails.
Types
@type get_response() :: {:ok, String.t()} | http_error() | transport_error()
@type headers() :: [header()]
@type http_error() :: {:http_error, {http_status(), String.t()}}
@type http_status() :: integer()
@type options() :: keyword()
@type payload() :: map()
@type post_response() :: success() | http_error() | transport_error()
@type success() :: {:ok, map()}
@type transport_error() :: {:transport_error, any()}
@type url() :: String.t()
Functions
@spec get(url(), headers(), query()) :: get_response()
Sends a GET request to the specified URL with the given headers and query parameters. Returns a tuple with the response status and body, or an error if the request fails.
Retries up to 10 times on 5xx HTTP responses and on select transient transport errors using exponential backoff with jitter.
@spec post_json(url(), headers(), payload()) :: post_response()
Sends a POST request with a JSON payload to the specified URL with the given headers. Returns a tuple with the response status and body, or an error if the request fails.
Retries up to 10 times on 5xx HTTP responses and on select transient transport errors using exponential backoff with jitter.