Integration examples and configuration templates for hadlink.
For deployment instructions, see DEPLOYMENT.md.
- CI Integration
- Configuration
- Monitoring Integration
- QR Code Generation
- Testing the API
- Advanced Usage
See ci-integration.sh for a complete example of integrating hadlink into CI/CD pipelines.
Usage:
# In your CI pipeline
export HADLINK_API="https://hadlink.home/api/create"
export HADLINK_KEY="ci"
export BUILD_URL="http://jenkins.local/job/foo/123/console"
./ci-integration.shThe script creates a short link and uses it in notifications.
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: make build
- name: Create short link
env:
HADLINK_API: ${{ secrets.HADLINK_API }}
HADLINK_KEY: ${{ secrets.HADLINK_KEY }}
run: |
BUILD_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
SHORT=$(curl -s "$HADLINK_API" \
-H "X-API-Key: $HADLINK_KEY" \
-d "url=$BUILD_URL" | jq -r '.short')
echo "Build results: $SHORT"build:
script:
- make build
after_script:
- |
SHORT=$(curl -s "$HADLINK_API" \
-H "X-API-Key: $HADLINK_KEY" \
-d "url=$CI_PIPELINE_URL" | jq -r '.short')
echo "Pipeline: $SHORT"See config.example.env for all available environment variables.
# Required — generate with: openssl rand -hex 16
export HADLINK_SECRET=<your-secret>
# Optional
export HADLINK_PORT=8443
export HADLINK_STORAGE=/var/lib/hadlink/hadlink.db
export HADLINK_BASE_URL=https://s.example.comWhen running behind nginx, Caddy, or another reverse proxy, enable X-Forwarded-For trust:
# Environment variable
export HADLINK_TRUST_PROXY=trueImportant: Only enable this when:
- hadlink is behind a trusted reverse proxy (nginx, Caddy, etc.)
- The proxy correctly sets the X-Forwarded-For header
- Direct access to hadlink is blocked (only proxy can reach it)
When disabled (default), rate limiting uses the direct socket address, which would be the proxy's IP if behind a reverse proxy.
# Grafana alert annotation
message: |
Disk usage critical on {{ $labels.instance }}
Details: {{ $labels.short_url }}Where short_url is pre-generated for each dashboard panel.
Use hadlink to create stable links for incident response:
# In alert webhook
INCIDENT_URL="https://status.example.com/incident/123"
SHORT=$(curl -s "$HADLINK_API" \
-H "X-API-Key: monitoring" \
-d "url=$INCIDENT_URL" | jq -r '.short')
# Include $SHORT in SMS/email notificationsCreate QR codes for physical infrastructure:
#!/bin/bash
# Generate QR code for router admin page
ADMIN_URL="http://192.168.1.1"
SHORT=$(curl -s "$HADLINK_API" \
-H "X-API-Key: infra" \
-d "url=$ADMIN_URL" | jq -r '.short')
# Generate QR code
qrencode -o router-admin.png "$SHORT"
# Print and affix to deviceSee the API Specification for complete endpoint documentation.
curl -X POST http://localhost:8443/api/create \
-H "X-API-Key: test" \
-d "url=https://example.com/very/long/path"Response:
{
"short": "http://localhost:8080/8F3kP2Q"
}curl -I http://localhost:8080/8F3kP2QResponse:
HTTP/1.1 302 Found
Location: https://example.com/very/long/path
Use different API keys for different services:
api_keys:
- name: ci
key: "ci-secret-key"
- name: monitoring
key: "monitoring-secret-key"
- name: infra
key: "infra-secret-key"Then track usage by key in logs.
For high-volume automated systems:
rate_limit:
per_ip: 100
window: 60
per_subnet: 500Or disable for authenticated keys in code.