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))
}
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)