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
t()
View Sourcet() :: %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
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}
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}
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"}
max_retries(config, max_retries)
View Sourcemax_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"}
request_timeout(config, request_timeout)
View Sourcerequest_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}
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"}