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 nameaddress: IP address stringkind: “added” or “removed”timestamp: Unix timestamp (seconds)
§Type Parameters
H: The HTTP client implementationS: The sleeper implementation for retry delays (defaults toTokioSleeper)
§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>
impl<H> HttpWebhook<H, TokioSleeper>
Sourcepub fn new(client: H, url: Url) -> Self
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>
impl<H, S> HttpWebhook<H, S>
Sourcepub fn with_sleeper<S2>(self, sleeper: S2) -> HttpWebhook<H, S2>
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.
Sourcepub fn with_method(self, method: Method) -> Self
pub fn with_method(self, method: Method) -> Self
Sets the HTTP method.
Sourcepub fn with_headers(self, headers: HeaderMap) -> Self
pub fn with_headers(self, headers: HeaderMap) -> Self
Sets the HTTP headers.
Sourcepub fn with_body_template(self, template: impl Into<String>) -> Self
pub fn with_body_template(self, template: impl Into<String>) -> Self
Sets the body template (Handlebars syntax).
Sourcepub const fn with_retry_policy(self, policy: RetryPolicy) -> Self
pub const fn with_retry_policy(self, policy: RetryPolicy) -> Self
Sets the retry policy.
Sourcepub const fn retry_policy(&self) -> &RetryPolicy
pub const fn retry_policy(&self) -> &RetryPolicy
Returns the configured retry policy.
Trait Implementations§
Source§impl<H: HttpClient, S: Sleeper> WebhookSender for HttpWebhook<H, S>
impl<H: HttpClient, S: Sleeper> WebhookSender for HttpWebhook<H, S>
Auto Trait Implementations§
impl<H, S> Freeze for HttpWebhook<H, S>
impl<H, S> RefUnwindSafe for HttpWebhook<H, S>where
H: RefUnwindSafe,
S: RefUnwindSafe,
impl<H, S> Send for HttpWebhook<H, S>
impl<H, S> Sync for HttpWebhook<H, S>
impl<H, S> Unpin for HttpWebhook<H, S>
impl<H, S> UnwindSafe for HttpWebhook<H, S>where
H: UnwindSafe,
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more