A Go application for handling webhooks from FireHydrant.com. This project demonstrates how to receive, verify, and process webhooks from FireHydrant's incident management platform.
- HTTP server using Gorilla Mux for routing
- HMAC signature verification for webhook security
- Configurable using command-line flags, environment variables, or config file
- JSON parsing of FireHydrant incident data
- Graceful shutdown handling
git clone https://github.com/bobbytables/firehydrant-webhook-handler-example.git
cd firehydrant-webhook-handler-example
go build -o firehydrant-webhook cmd/firehydrant/main.go
The application supports multiple commands:
server
: Start the webhook serverversion
: Display version information
# Run with default settings
./firehydrant-webhook server
# Specify port and HMAC secret
./firehydrant-webhook server -p 9000 -s your-webhook-secret
# Enable debug mode
./firehydrant-webhook server -d
# Use a specific config file
./firehydrant-webhook server -c /path/to/config.yaml
./firehydrant-webhook version
Configuration can be provided through:
- Command-line flags
- Environment variables
- Config file (YAML)
-p, --port
: HTTP server port (default: 8080)-s, --secret
: HMAC secret for webhook verification-d, --debug
: Enable debug mode for verbose logging-c, --config
: Path to config file
Environment variables use the prefix FH_
and convert dots to underscores:
FH_SERVER_PORT
: HTTP server portFH_WEBHOOK_SECRET
: HMAC secret for webhook verificationFH_WEBHOOK_DEBUG
: Enable debug mode (true/false)
The default config file is config.yaml
in the current directory. You can specify a different file with the -c
flag.
Example config.yaml
:
server:
port: 8080
webhook:
# Secret used for HMAC verification
secret: your-webhook-secret
# Enable debug mode
debug: false
- In FireHydrant, go to Settings > Integrations > Webhooks
- Add a new webhook with your server's URL (e.g.,
https://your-server.com/webhook
) - Set the webhook secret and use the same value in your webhook handler configuration
- Select the incident events you want to receive
- Save the webhook configuration
The application uses HMAC-SHA256 to verify webhook requests from FireHydrant. When a webhook is sent, FireHydrant includes a signature in the fh-signature
header. The application computes its own signature using the shared secret and compares it with the provided signature.
To generate a secure random secret, you can use:
openssl rand -hex 32
To customize how webhooks are processed, modify the processWebhook
method in internal/handler/webhook.go
. This method receives the parsed webhook payload and can be extended to:
- Update data lakes
- Update an internal database
- Send notifications
- Trigger automated responses
- Forward to other systems
MIT