Skip to main content

Crate zeph_gateway

Crate zeph_gateway 

Source
Expand description

HTTP gateway for webhook ingestion with bearer-token auth and health endpoint.

zeph-gateway exposes two HTTP endpoints over a single TCP listener:

EndpointMethodAuth requiredPurpose
/healthGETNoLiveness check; returns uptime in seconds
/webhookPOSTYes (if token set)Ingest external events into the agent

§Security model

§Rate limiting

Requests to /webhook are rate-limited per remote IP using a fixed-window counter with a 60-second window. The default ceiling is 120 requests per window and is configurable via GatewayServer::with_rate_limit. Setting the limit to 0 disables rate limiting.

§Quick start

use tokio::sync::{mpsc, watch};
use zeph_gateway::{GatewayServer, WebhookMessage};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let (webhook_tx, mut webhook_rx) = mpsc::channel::<WebhookMessage>(64);
    let (_shutdown_tx, shutdown_rx) = watch::channel(false);

    tokio::spawn(async move { // EXEMPT: doc-example only
        while let Some(msg) = webhook_rx.recv().await {
            println!("received: {msg:?}");
        }
    });

    GatewayServer::new("127.0.0.1", 8080, webhook_tx, shutdown_rx)
        .with_auth(Some("my-secret-token".into()))
        .with_rate_limit(60)
        .serve()
        .await?;

    Ok(())
}

Structs§

GatewayServer
HTTP gateway server with bearer-auth, rate limiting, and body-size enforcement.
WebhookMessage
A validated, control-character-stripped webhook payload forwarded to the agent-input forwarder (forward_webhooks in the zeph binary).

Enums§

GatewayError
Errors that can be returned by the HTTP gateway.