← Back to all products

Webhook Router

$19

Lightweight HTTP webhook receiver and router with URL-based routes, HMAC validation, and delivery tracking.

📁 9 files
JSONMarkdownPython

📄 Product Preview

Try the interactive reader and demo tools below, or get the full product with all content unlocked.

📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample

📁 File Structure 9 files

webhook-router/ ├── LICENSE ├── README.md ├── examples/ │ └── webhook_config.json ├── free-sample.zip ├── guide/ │ ├── 01_features.md │ ├── 02_quick-start.md │ └── 03_faq.md ├── index.html └── src/ └── webhook_router.py

📖 Documentation Preview README excerpt

Webhook Router

A lightweight HTTP webhook receiver and router built on Python stdlib. Define URL-based routes, validate payloads with HMAC signatures, filter by event type, retry failed forwards with exponential backoff, and log every event to SQLite.

Features

  • URL-based routing — Pattern-match incoming webhook paths to specific handlers
  • HMAC signature verification — Validate webhook authenticity (Stripe, GitHub, etc.)
  • Payload validation — JSON schema-style checks on incoming payloads
  • Event filtering — Route based on event type headers or payload fields
  • Retry with backoff — Forward events to downstream URLs with exponential backoff
  • Event persistence — Log all events to SQLite for audit and replay
  • Configurable via JSON — Define routes, secrets, and forwarding targets in a config file
  • Request logging — Structured logging of every incoming request

Requirements

  • Python 3.10+
  • No external dependencies (stdlib only)

Quick Start


# Start the router with default catch-all route on port 8080
python src/webhook_router.py

# Start with a config file
python src/webhook_router.py --config examples/webhook_config.json

# Custom port and logging
python src/webhook_router.py --port 9000 --log-file webhooks.log --log-level DEBUG

Send a test webhook:


curl -X POST http://localhost:8080/hooks/test \
  -H "Content-Type: application/json" \
  -d '{"event": "test.ping", "data": {"message": "hello"}}'

Configuration Reference

Create a JSON config file for production setups:


{
    "port": 8080,
    "host": "0.0.0.0",
    "database": "webhooks.db",
    "routes": [
        {
            "name": "stripe-payments",
            "path_pattern": "/hooks/stripe",
            "secret": "whsec_YOUR_STRIPE_WEBHOOK_SECRET",
            "signature_header": "Stripe-Signature",
            "forward_url": "https://api.example.com/v1/payment-events",
            "event_filter": ["charge.succeeded", "invoice.paid"]
        },
        {

*... continues with setup instructions, usage examples, and more.*

📄 Code Sample .py preview

src/webhook_router.py #!/usr/bin/env python3 """ Webhook Router — Automation Hub (DataNest) A lightweight HTTP webhook router built on Python stdlib. Supports URL-based routing, JSON payload validation, event type filtering, retry with exponential backoff, request logging, and signature verification. Usage: python webhook_router.py --port 8080 python webhook_router.py --config webhook_config.json python webhook_router.py --port 9000 --log-file webhooks.log Dependencies: Python 3.10+ stdlib only (no pip packages) License: MIT """ from __future__ import annotations import argparse import hashlib import hmac import http.server import json import logging import queue import re import sqlite3 import threading import time import urllib.parse import urllib.request from dataclasses import dataclass, field from datetime import datetime, timezone from enum import Enum from pathlib import Path from typing import Any, Callable # --------------------------------------------------------------------------- # Constants # --------------------------------------------------------------------------- DEFAULT_PORT = 8080 MAX_PAYLOAD_BYTES = 1_048_576 # 1 MB MAX_RETRY_ATTEMPTS = 5 INITIAL_RETRY_DELAY_S = 1.0 BACKOFF_MULTIPLIER = 2.0 LOG_FORMAT = "%(asctime)s [%(levelname)s] %(name)s: %(message)s" logger = logging.getLogger("webhook_router") # ... 660 more lines ...
Buy Now — $19 Back to Products