hivehook 0.1.0

Official Hivehook Rust SDK
docs.rs failed to build hivehook-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

hivehook (Rust)

Official Rust client for Hivehook, the self-hostable webhook gateway (inbound + outbound).

Install

[dependencies]
hivehook = "0.1"

Or:

cargo add hivehook

Quick start

use hivehook::HivehookClient;
use hivehook::resources::sources::CreateSourceInput;
use serde_json::json;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = HivehookClient::new(
        "http://localhost:8080",
        Some(std::env::var("HIVEHOOK_API_KEY")?),
    )?;

    let source = client.sources().create(CreateSourceInput {
        name: "Stripe production".into(),
        slug: "stripe-prod".into(),
        provider_type: "stripe".into(),
        verify_config: Some(json!({ "secret": "whsec_..." })),
        ..Default::default()
    })?;

    println!(
        "created source {}. POST webhooks to /ingest/{}",
        source.id, source.slug
    );
    Ok(())
}

Webhook signature verification

use hivehook::Webhook;

let signature = headers.get("x-hivehook-signature").unwrap();
let timestamp: i64 = headers.get("x-hivehook-timestamp").unwrap().parse().unwrap();
let ok = Webhook::verify(body, "your-signing-secret", signature, timestamp, Some(300));

Documentation

See the full reference at hivehook.com/docs.

License

MIT. See LICENSE.