webhooks_emitter v0.1.0 WebhooksEmitter.Config View Source

Webhook emitter configuration.

Link to this section Summary

Functions

Set additional HTTP header to be sent along with the http request. Can be called multiple times.

Allow SSL insecure requests.

Disallow SSL insecure requests (the default).

Allows to change the private header identifier. By default is Webhooks, so all private headers set by this library will have X-Webhooks prefix.

Set the number of max retries for each delivery. Defaults to 3.

Returns a new emitter config with the destination url set.

Set the HTTP request timeout, in milliseconds. By default is 5 seconds (5000 msec).

Add a secret, which is used to compute the hmac hex digest of the body.

Link to this section Types

Link to this type

header_content()

View Source
header_content() :: String.t()
Link to this type

header_name()

View Source
header_name() :: String.t()
Link to this type

headers()

View Source
headers() :: [header()]
Link to this type

t()

View Source
t() :: %WebhooksEmitter.Config{
  additional_headers: headers(),
  backoff_limit: non_neg_integer(),
  backoff_start: non_neg_integer(),
  header_identifier: String.t(),
  http_client: module(),
  insecure: boolean(),
  max_retries: non_neg_integer(),
  request_timeout: non_neg_integer(),
  secret: nil | String.t(),
  url: nil | String.t()
}

Link to this section Functions

Link to this function

additional_header(config, additional_header)

View Source
additional_header(t(), header()) :: t()

Set additional HTTP header to be sent along with the http request. Can be called multiple times.

## Examples
  iex> "https://host.tld/hooks"
  ...> |> WebhooksEmitter.Config.new()
  ...> |> WebhooksEmitter.Config.additional_header({"authorization", "bearer 4242"})
  %WebhooksEmitter.Config{url: "https://host.tld/hooks", additional_headers: [{"authorization", "bearer 4242"}]}

  iex> "https://host.tld/hooks"
  ...> |> WebhooksEmitter.Config.new()
  ...> |> WebhooksEmitter.Config.additional_header({"authorization", "bearer 4242"})
  ...> |> WebhooksEmitter.Config.additional_header({"Access-Control-Allow-Origin", "*"})
  %WebhooksEmitter.Config{url: "https://host.tld/hooks", additional_headers: [{"Access-Control-Allow-Origin", "*"}, {"authorization", "bearer 4242"}]}

Allow SSL insecure requests.

Examples

  iex> WebhooksEmitter.Config.new("https://host.tld/hooks")
  ...> |> WebhooksEmitter.Config.allow_insecure()
  %WebhooksEmitter.Config{url: "https://host.tld/hooks", insecure: true}
Link to this function

disallow_insecure(config)

View Source

Disallow SSL insecure requests (the default).

Examples

  iex> WebhooksEmitter.Config.new("https://host.tld/hooks")
  ...> |> WebhooksEmitter.Config.disallow_insecure()
  %WebhooksEmitter.Config{url: "https://host.tld/hooks", insecure: false}
Link to this function

header_identifier(config, header_identifier)

View Source
header_identifier(t(), String.t()) :: t()

Allows to change the private header identifier. By default is Webhooks, so all private headers set by this library will have X-Webhooks prefix.

## Examples
  iex> "https://host.tld/hooks"
  ...> |> WebhooksEmitter.Config.new()
  ...> |> WebhooksEmitter.Config.header_identifier("Yourapp")
  %WebhooksEmitter.Config{url: "https://host.tld/hooks", header_identifier: "Yourapp"}
Link to this function

max_retries(config, max_retries)

View Source
max_retries(t(), pos_integer()) :: t()

Set the number of max retries for each delivery. Defaults to 3.

## Examples
  iex> "https://host.tld/hooks"
  ...> |> WebhooksEmitter.Config.new()
  ...> |> WebhooksEmitter.Config.max_retries(43)
  %WebhooksEmitter.Config{url: "https://host.tld/hooks", max_retries: 43}

Returns a new emitter config with the destination url set.

Examples

  iex> WebhooksEmitter.Config.new("https://host.tld/hooks")
  %WebhooksEmitter.Config{url: "https://host.tld/hooks"}
Link to this function

request_timeout(config, request_timeout)

View Source
request_timeout(t(), pos_integer()) :: t()

Set the HTTP request timeout, in milliseconds. By default is 5 seconds (5000 msec).

## Examples
  iex> "https://host.tld/hooks"
  ...> |> WebhooksEmitter.Config.new()
  ...> |> WebhooksEmitter.Config.request_timeout(2000)
  %WebhooksEmitter.Config{url: "https://host.tld/hooks", request_timeout: 2000}
Link to this function

secret(config, secret)

View Source
secret(t(), String.t()) :: t()

Add a secret, which is used to compute the hmac hex digest of the body.

## Examples

  iex> "https://host.tld/hooks"
  ...> |> WebhooksEmitter.Config.new()
  ...> |> WebhooksEmitter.Config.secret("supersecret")
  %WebhooksEmitter.Config{url: "https://host.tld/hooks", secret: "supersecret"}