DEV Community

gofuckbiz
gofuckbiz

Posted on

Building a Universal Webhook Adapter in Go: Introducing WHOOK

Building a Universal Webhook Adapter in Go: Introducing WHOOK

The Problem

As a developer working with multiple services, I've always struggled with webhook management. Each service (Stripe, GitHub, Telegram) has its own webhook format, authentication method, and verification process. This leads to:

  • Code duplication across different webhook handlers
  • Security risks from inconsistent signature verification
  • Maintenance nightmares when services update their APIs
  • Time waste rewriting similar logic for each integration

The Solution: WHOOK

I built WHOOK - a universal webhook adapter for Go that solves these problems with a clean, extensible architecture.

Key Features

πŸ”’ Built-in Security: Automatic signature verification for all providers
πŸš€ High Performance: >10,000 RPS with minimal memory usage
πŸ”§ Flexible: Easy to extend with custom providers
πŸ“¦ Simple: Minimal setup, maximum functionality
πŸ›‘οΈ Reliable: Comprehensive error handling and logging

Quick Start

package main

import (
    "log"
    "net/http"

    "github.com/gofuckbiz/WHOOK"
    "github.com/gofuckbiz/WHOOK/providers"
)

func main() {
    router := whook.NewRouter()

    // Stripe webhooks
    stripeProvider := providers.NewStripeProvider("your-stripe-secret")
    router.Register("/webhook/stripe", stripeProvider, func(event *whook.Event) error {
        log.Printf("Stripe event: %s", event.Type)
        // Handle payment events
        return nil
    })

    // GitHub webhooks
    githubProvider := providers.NewGitHubProvider("your-github-secret")
    router.Register("/webhook/github", githubProvider, func(event *whook.Event) error {
        log.Printf("GitHub event: %s", event.Type)
        // Handle repository events
        return nil
    })

    log.Println("Starting webhook server on :8080")
    log.Fatal(http.ListenAndServe(":8080", router))
}
Enter fullscreen mode Exit fullscreen mode

Supported Providers

  • βœ… Stripe - Payment events with HMAC-SHA256 verification
  • βœ… GitHub - Repository and CI/CD events
  • βœ… Telegram - Bot events with secret token verification

Architecture

WHOOK follows a clean, extensible architecture:

Top comments (0)