HttpWebhook

Struct HttpWebhook 

Source
pub struct HttpWebhook<H, S = TokioSleeper> { /* private fields */ }
Expand description

HTTP-based webhook sender with retry support.

Sends IP change notifications via HTTP requests, with configurable retry behavior using exponential backoff.

§Template Support

The body can be templated using Handlebars syntax. Available variables:

  • changes: Array of change objects, each with:
    • adapter: Adapter name
    • address: IP address string
    • kind: “added” or “removed”
    • timestamp: Unix timestamp (seconds)

§Type Parameters

  • H: The HTTP client implementation
  • S: The sleeper implementation for retry delays (defaults to TokioSleeper)

§Example

use ddns_a::webhook::{HttpWebhook, ReqwestClient, RetryPolicy};
use url::Url;

let webhook = HttpWebhook::new(
    ReqwestClient::new(),
    Url::parse("https://api.example.com/ddns").unwrap(),
);

Implementations§

Source§

impl<H> HttpWebhook<H, TokioSleeper>

Source

pub fn new(client: H, url: Url) -> Self

Creates a new HTTP webhook with default settings.

Uses POST method, no custom headers, no body template, default retry policy, and TokioSleeper for delays.

Source§

impl<H, S> HttpWebhook<H, S>

Source

pub fn with_sleeper<S2>(self, sleeper: S2) -> HttpWebhook<H, S2>

Sets a custom sleeper for retry delays.

This is primarily useful for testing to avoid actual delays.

Source

pub fn with_method(self, method: Method) -> Self

Sets the HTTP method.

Source

pub fn with_headers(self, headers: HeaderMap) -> Self

Sets the HTTP headers.

Source

pub fn with_body_template(self, template: impl Into<String>) -> Self

Sets the body template (Handlebars syntax).

Source

pub const fn with_retry_policy(self, policy: RetryPolicy) -> Self

Sets the retry policy.

Source

pub const fn url(&self) -> &Url

Returns the configured URL.

Source

pub const fn method(&self) -> &Method

Returns the configured HTTP method.

Source

pub const fn retry_policy(&self) -> &RetryPolicy

Returns the configured retry policy.

Trait Implementations§

Source§

impl<H: Debug, S: Debug> Debug for HttpWebhook<H, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<H: HttpClient, S: Sleeper> WebhookSender for HttpWebhook<H, S>

Source§

async fn send(&self, changes: &[IpChange]) -> Result<(), WebhookError>

Sends a notification about IP address changes. Read more

Auto Trait Implementations§

§

impl<H, S> Freeze for HttpWebhook<H, S>
where H: Freeze, S: Freeze,

§

impl<H, S> RefUnwindSafe for HttpWebhook<H, S>

§

impl<H, S> Send for HttpWebhook<H, S>
where H: Send, S: Send,

§

impl<H, S> Sync for HttpWebhook<H, S>
where H: Sync, S: Sync,

§

impl<H, S> Unpin for HttpWebhook<H, S>
where H: Unpin, S: Unpin,

§

impl<H, S> UnwindSafe for HttpWebhook<H, S>
where H: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more