No description
Find a file
2024-10-22 14:54:38 +07:00
.github/workflows ci: add Docker buid workflow 2024-01-31 18:27:18 +07:00
examples test: more complex alertmanager to ntfy example 2024-03-30 11:05:21 +07:00
src refactor!: expose all environment variables 2024-02-14 11:04:37 +07:00
.envrc Initial commit 2024-01-26 01:15:57 +07:00
.gitignore Initial commit 2024-01-26 01:15:57 +07:00
Cargo.lock refactor: use rustls 2024-01-31 18:11:31 +07:00
Cargo.toml refactor: use rustls 2024-01-31 18:11:31 +07:00
flake.lock Initial commit 2024-01-26 01:15:57 +07:00
flake.nix ci: add Docker buid workflow 2024-01-31 18:27:18 +07:00
LICENSE.md docs: add license 2024-01-29 18:15:18 +07:00
Makefile ci: add simple CI target 2024-10-22 14:54:38 +07:00
README.md refactor!: expose all environment variables 2024-02-14 11:04:37 +07:00
rust-toolchain.toml Initial commit 2024-01-26 01:15:57 +07:00

Webhook Transformer

Warning

Alpha software

A small application that listens for incoming HTTP POST requests, transforms the payload using a provided Jsonnet configuration, and then forwards the transformed payload to an upstream host. This is useful as an adapter to integrate applications that don't support each other's webhook formats.

Usage

There's a pre-compiled Docker image that you can use:

docker run \
    -p 8080 \
    -v /path/to/config.jsonnet:/config.jsonnet \
    ghcr.io/khuedoan/webhook-transformer:v0.0.1 --config /config.jsonnet

The transformer automatically injects some global variables:

Name Type Description
body object The JSON payload from the webhook
env object Key-value pairs of environment variables

I personally run it as a Kubernetes sidecar to transform Alertmanager webhooks to ntfy format, but you can use it to transform anything you like. There are some examples in the examples/ directory:

Development

Open the Nix shell:

nix develop

Run the server:

make dev

The default development server will transform Alertmanager request and forward it to ntfy. You can visit https://ntfy.sh/webhook-transformer and try it out:

curl \
    --request POST \
    --header "Content-Type: application/json" \
    --data @examples/alertmanager-to-ntfy/input.json \
    http://localhost:8080

After making your changes, run the test suite:

make test