Webhook infrastructure for external event notifications: - SQL migration: webhook_subscriptions + webhook_deliveries tables - Types: CreateWebhookRequest, UpdateWebhookRequest, WebhookDelivery - Service: CRUD operations + trigger_webhooks + HMAC-SHA256 signing - Handlers: REST API endpoints (CRUD + delivery logs) - Worker: WebhookDeliveryWorker with exponential retry (max 3) NOT YET INTEGRATED: needs mod registration in lib.rs + workers/mod.rs, hmac crate dependency, and route mounting. Code is ready for future integration after stabilization phase completes.
19 lines
729 B
Rust
19 lines
729 B
Rust
//! Webhook 模块 — 事件通知系统
|
|
//!
|
|
//! 允许 SaaS 平台在事件发生时向外部 URL 发送 HTTP POST 通知。
|
|
//! 支持 HMAC-SHA256 签名验证、投递日志和自动重试。
|
|
|
|
pub mod types;
|
|
pub mod service;
|
|
pub mod handlers;
|
|
|
|
use crate::state::AppState;
|
|
|
|
/// Webhook 路由 (需要认证)
|
|
pub fn routes() -> axum::Router<AppState> {
|
|
axum::Router::new()
|
|
.route("/api/v1/webhooks", axum::routing::get(handlers::list_subscriptions).post(handlers::create_subscription))
|
|
.route("/api/v1/webhooks/:id", axum::routing::patch(handlers::update_subscription).delete(handlers::delete_subscription))
|
|
.route("/api/v1/webhooks/:id/deliveries", axum::routing::get(handlers::list_deliveries))
|
|
}
|